Monday, August 25, 2014

Search and Replace in all files within a directory recursively on Linux


To search recursively through directories, looking in all the files for a particular string, and to replace that string with some string,  use:

find ./ -type f -exec sed -i 's/string1/string2/' {} \;

Where string1 is the search string and string2 is the replace string.



No comments:

Post a Comment