Super User is a question and answer site for computer enthusiasts and power users. 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

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .