# find and regex



## clinty (Feb 27, 2009)

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 (Feb 27, 2009)

find -E should help.


----------



## clinty (Feb 27, 2009)

Uh... I'm looking for a correction of my actual regex. Could you help me?


----------



## DutchDaemon (Feb 27, 2009)

Try


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

or


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

of course.


----------



## clinty (Feb 27, 2009)

DutchDaemon said:
			
		

> Try
> 
> 
> ```
> ...


Oh yeah, it works! Thanks a lot!


----------

