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

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

What would be the command?


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
  • 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
  • 1
    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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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