Skip to main content

Linux - Replace string in all files recursively

Please use with caution!

Finding the keyword:
grep -rs keyword
-r - recursively
-s - ignore error messages
Search is case-sensitive - use -i to deactivate
Replacing it:
find . -type f -exec sed -i 's/what/helloo/g' {} ';'
is case-sensitive

Bonus: rename only files in the current directory use the -maxdepth 1 option like find . -maxdepth 1 -type f [...].