How to search and replace using grep

grep, linux, replace, shell

Solution

Another option is to use find and then pass it through sed.

find /path/to/files -type f -exec sed -i 's/oldstring/new string/g' {} \;

Problem

I need to recursively search for a specified string within all files and subdirectories within a directory and replace this string with another string. I know that the command to find it might look like this: ``` grep 'string_to_find' -r ./* ``` But how can I replace every instance of `string_to_find` with another string?

Original source

Related problems