Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am executing this command to find certain files in specific directory:

find ./rgs/test/maesXX/master/stdlist -name \*.extract \
     -mtime +30 \! -size 0 -exec ls -lrt {} \;

where XX could be any number between 1-100.

Can I use a regex for this purpose? How would I do that? Are there other ways?

share|improve this question
Thanks for editing @Mat...It looks better now – munish Jan 11 '12 at 6:44
up vote 8 down vote accepted

You can pass more than one path to find, so the best way (IMHO) is to let the shell do the expansion.

If you don't have other directories starting with maes there, then this should suffice, and is simpler:

find ./rgs/test/maes*/master/stdlist ...

But if you really need to match that pattern exactly, you can do

find ./rgs/test/maes[0-9][0-9]/master/stdlist ...

for maes00 -- maes99, or

find ./rgs/test/maes{[1-9],[1-9][0-9],100}/master/stdlist ...

for maes1 -- maes100 (I didn't get which one was your case).

share|improve this answer
thanks i get it – munish Jan 11 '12 at 6:59

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.