Linux

How to replace a string in several files

This is a linux/*nix based solution that allows to recursively search and replace a pattern in all the files matching a certain pattern.

find . -iname "file_pattern" -type f -exec sed -i 's/search_pattern/replacement/g' {} \;

file_pattern: The pattern for matching the files to be modified.
search_pattern: The pattern to look for inside the file.
replace_pattern: The text that should replace search_pattern inside the file.

Subscribe to RSS - Linux