3

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?

1 Answer 1

5

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.

2
  • Thanks dude. Can i ask another question here in the comment please? what does this line mean: grep foo bar Apr 30, 2013 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, 2013 at 8:11

You must log in to answer this question.

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