Please use with caution!
- Finding lines containing the keyword:
grep -rs keyword
-r
- recursively-s
- ignore error messages- Search is case-sensitive - use
-i
to deactivate - Deleting lines in all files containing a certain keyword recursively:
find . -type f -print0 | xargs -0 sed -i /keyword/d
- it is case-sensitive!
- Bonus: if you only want to delete the keyword and not the whole lines:
find . -type f -print0 | xargs -0 sed -i s/keyword//g
Bonus: rename only files in the current directory
use the -maxdepth 1
option like find . -maxdepth 1 -type f [...]
.
Most recent Articles: