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

I want to rm all the files that I get when I run

find search-3S-beta |grep "\.log\."

What would be the command?

share|improve this question
up vote 11 down vote accepted

Find can do the deletion for you using the -delete option. Combining the rest of your command into a single find line, this will become:

find search-3S-beta -name '*.log.*' -delete
share|improve this answer
or find search-3S-beta -name '*.log.*' -print0 |xargs -0 rm – McNisse Jan 17 '13 at 21:32
Why would you do that instead of find ... -delete? – Dennis Kaarsemaker Jan 17 '13 at 21:35
@DennisKaarsemaker "Feature [...] -delete Added in 4.2.3" (from find(1)) But yeah, I don't see any use either. Just use -delete if available. – gertvdijk Jan 18 '13 at 1:40
4.2.3 was released over 8 years ago, in 2004. So this is available even at the slowest updaters by now. – Dennis Kaarsemaker Jan 18 '13 at 6:48
No, it is not. You need to type more, so it's not efficient on your fingers, and you're launching an extra process to do the deletion, so it's not more efficient for the computer either. – Dennis Kaarsemaker Jan 18 '13 at 12:00

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.