Possible Duplicate:
Delete files recursively matching a name on the command line (OS X)

I want to remove all files with extension .orig from my tree. The tree is deep. Is there an easy way to do that?

I will probably have to do this many times a day, with different trees. So ease is important.

link|improve this question

feedback

closed as exact duplicate by Daniel Beck, grawity, studiohack Feb 3 '11 at 23:08

This question covers exactly the same ground as earlier questions on this topic; its answers may be merged with another identical question. See the FAQ for guidance on how to improve it.

3 Answers

up vote 3 down vote accepted
find /path -name '*.orig' -delete
link|improve this answer
1  
I habitually add find's -x flag (find -x /path ...) to keep it from crossing mount points onto other volumes. It's usually irrelevant, but I'd rather be safe than sorry. – Gordon Davisson Feb 3 '11 at 20:48
feedback

I prefer this method (very similar to @grawity) but with the type of file included:

find /path . -name '*.orig' -type f -delete

link|improve this answer
feedback

Can you execute shell commands in bash? This would do the trick:

find /path/to/your/tree | egrep .orig$ | xargs rm
link|improve this answer
feedback

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