Super User is a question and answer site for computer enthusiasts and power users. 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

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.

share|improve this question

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

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

up vote 17 down vote accepted
find /path -name '*.orig' -delete
share|improve this answer
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
To search in the current folder (including sub folders) find . -name... – Alex Ilyaev Jul 9 at 23:25

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

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

share|improve this answer

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

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

Not the answer you're looking for? Browse other questions tagged .