Friday, March 23, 2012

pipe with rm

I wanted to delete a large number of files in a directory that satisfied a certain criteria in their name.  The command for this is:


find /path/to/dir -name '*criteria*' -exec rm {} \;

or



find /path/to/dir -name '*criteria*'| xargs rm

or


ls | grep criteria | xargs rm


Note: The last command might be slower than the first two.

No comments:

Post a Comment