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