Find Replace Script
The following is a little shell script that recursively finds within a folder all the files that contains a given string and replaces all the instances of the string with another given string. This is really helpful for making sweeping changes among a collection of files, without having to edit each file individually.
There are two ways to use the script: with or without a file extension to limit the search. If no file extension is given, all files will be considered. Assuming the script is called ‘frpl’, here is the usage:
frpl searchstring replacestring [fileextension]
Here are some example usages. Note that special characters need to be escaped, and that strings with white spaces can be made with double or single quotes.
frpl this that frpl "this one" "those two" html frpl \$DOCUMENT_ROOT \$_SERVER['DOCUMENT_ROOT'] php