A little regex help please ...

Matt Davey mcdavey at mrao.cam.ac.uk
Mon Jul 10 15:35:05 UTC 2006


On Mon, 2006-07-10 at 07:49 -0700, Brian D. McGrew wrote:
> Regex has always been a mystery to me, any help would be great!

As someone else pointed out, you're doing 'globbing', or pathname
expansion.  If you do want to learn and debug POSIX style regular
expressions, I highly recommend regex-coach.  You can type in a regex,
and some text, and see what it matches.  Lots of features.

See:
http://weitz.de/regex-coach/

p.s. If I've understood what you want, my solution would be:

#!/bin/bash
shopt -s extglob
for file in *[0-9].*[0-9].*[0-9] ; do
	# stuff
done

this will iterate over all files/directories of the form
number.number.number and ignore everything else.

Matt
Matt Davey		Make it as simple as possible, but no simpler.
mcdavey at mrao.cam.ac.uk 			     Einstein.




More information about the fedora-list mailing list