[Melbourne-pm] I <3 map & grep

Sam Watkins sam at nipl.net
Wed Oct 26 23:17:18 PDT 2011


On Thu, Oct 27, 2011 at 04:34:37PM +1100, Toby Corkindale wrote:
> I think I was going to use my regex to eliminate files such as
> .filename.swp and the like, but that's not what it's doing now.
> I should fix it up.

> >                    grep { /^[-_a-zA-Z\d\.]+$/ }

Yeah you don't want those pesky hidden files matching with the . !

This seems to do it:

	grep { /^\w[-\w\.]*$/ }

Tested with:

	ls -a | perl -ne 'print if /^\w[-\w\.]*$/' | less
	ls -a | perl -ne 'print if !/^\w[-\w\.]*$/' | less

  in my home directory, which has plenty of weird filenames in it!

Sam


More information about the Melbourne-pm mailing list