Find and delete files with specific content

Posted on Wednesday, July 1st, 2009 at 1:49 am in

Ever wanted to deleted (or move, copy, what else) all files in a directory? It’s quite easy:

egrep -l NEEDLE * | xargs rm

This command will find all files with NEEDLE in it, pipes the filename (that’s because we need the parameter L) to xargs which then use the STDIN (our filename) and put’s it to rm.

Just play around with it the possible parameters. It would save you a lot of time.


Add your comment

Leave a Reply

Leave A Comment