find and regex

clinty

Member


Messages: 69

Hello.

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

So this instruction works:

Code:
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:

Code:
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
 

DutchDaemon

Administrator
Staff member
Administrator
Moderator
Developer

Reaction score: 2,827
Messages: 11,313

Try

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

Code:
find -E Junk/ -regex '(.*/cur/.*|.*/new/.*)' etc.
of course.
 
OP
OP
clinty

clinty

Member


Messages: 69

DutchDaemon said:
Try

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

Code:
find -E Junk/ -regex '(.*/cur/.*|.*/new/.*)' etc.
of course.
Oh yeah, it works! Thanks a lot!
 
Top