Pages

Removing the files containing a match word/string

If you have a number of files and want to remove only those files with a matching line

Option 1: Using echo to check

for file in $(grep -l error *); do echo rm -i $file; done

Option 2: Prompt each time

for file in $(grep -l error *); do echo rm -i $file; done


Note: here | grep -l | gives the files with matching string.


No comments:

Post a Comment

You may be interested in these posts

Error in image file conversion: convert-im6.q16: not authorized `test.eps' @ error/constitute.c/WriteImage/1037.

This error is because of the vulnerability. This allows remote execution of code using image formats. So, some Linux distributions by defaul...