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?
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
.
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).