PDA

View Full Version : [Solved] find and regex


clinty
February 27th, 2009, 18:15
Hello.

I'm creating a script which delete all mails older than 45 days in .Junk directory.

So this instruction works:

find . -regex '.*Junk/cur/.*' -ctime +45 -maxdepth 5 -print


It works. I see all my expired mails. However, I want to remove expired mails in Junk/cur and Junk/new. I does not want to create 2 commands.

This instruction does not work:

find . -regex '.*Junk/\(cur\|new\)/.*' -ctime +0 -maxdepth 5 -print


I have no errors. No mails are listed. Do you have any idea? My OR does not work in this instruction.

Thanks a lot.

Regards

mjguzik
February 27th, 2009, 18:23
find -E should help.

clinty
February 27th, 2009, 18:26
Uh... I'm looking for a correction of my actual regex. Could you help me?

DutchDaemon
February 27th, 2009, 18:28
Try

find -E . -regex '(.*Junk/cur/.*|.*Junk/new/.*)' etc.

or

find -E Junk/ -regex '(.*/cur/.*|.*/new/.*)' etc.

of course.

clinty
February 27th, 2009, 18:32
Try

find -E . -regex '(.*Junk/cur/.*|.*Junk/new/.*)' etc.

or

find -E Junk/ -regex '(.*/cur/.*|.*/new/.*)' etc.

of course.
Oh yeah, it works! Thanks a lot!