Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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
add comment

1 Answer

up vote 5 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
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
show 2 more comments

Your Answer

 
discard

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.