Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How do I find a file matching a pattern and then delete all of it? Something like

find -name 'pattern%'

Then how to delete all of found entries?

share|improve this question

1 Answer 1

up vote 4 down vote accepted

From Deleting Files of the find manual:

10.1.6 Using the -delete action

The most efficient and secure method of solving this problem is to use the ‘-delete’ action:

find /var/tmp/stuff -mtime +90 -delete

So, just call find -name 'pattern%' -delete.

share|improve this answer
    
Thanks dude. Can i ask another question here in the comment please? what does this line mean: grep foo bar –  Belmark Caday Apr 30 '13 at 8:06
    
That'd mean you search foo in a file called bar. But this shouldn't be hard to find out if you read the manuals of the commands/programs you're using. See man grep (and man find for the answer to your initial question). –  slhck Apr 30 '13 at 8:11

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.