Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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

When I revert in Mercurial, it leaves several .orig files. I would like to be able to run a command to remove all of them.

I have found some sources that say to run:

rm **/*.orig

But that gives me the message:

rm: cannot remove `*/.orig': No such file or directory

I have also tried:

  • rm -rv *.orig

  • rm -R *\.orig

share|improve this question
up vote 48 down vote accepted

Use the find command (with care!)

find . -name '*.orig' #-delete

I've commented out the delete command but once you're happy with what it's matching, just remove the # from the line and it should delete all those files.

share|improve this answer
Does that work recursively? – Frank Barcenas May 25 '13 at 22:15
@FrankBarcenas Yeah - find does everything recursively. If you want to limit how that works, you can play with the -maxdepth or -mindepth arguments. – Oli May 26 '13 at 9:37
Definitely leave the -delete at the end of the flags. find . -delete -name '*.orig' will ignore the filter and clobber your whole directory. – Michael Nov 18 '15 at 17:02

"find" has some very advanced techniques to search through all or current directories and rm files.

find ./ -name ".orig" -exec rm -rf {} \;
share|improve this answer
What's the benefit over using -delete? – muru Dec 7 '15 at 22:25
@muru I suppose you'd get a prompt for each file if you remove -rf. – Peter Jul 12 at 21:06
@Peter not necessarily. Even then, so? The answer uses -rf, and find has -ok. – muru Jul 12 at 21:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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