A good replacement Linux tool is rpl, that was originally written for the Debian project, so it is available with
apt-get install rpl in any Debian derived distro, and may be for others, but otherwise you can download the
tar.gz file in SourgeForge.
Simplest example of use:
$ rpl old_string new_string test.txt
Note that if the string contain spaces it should be enclosed in quotation marks. By default
rpl take care of capital letters but not of complete words, but you can change these defaults with options
-i (ignore case) and
-w (whole words). You can also specify multiple files:
$ rpl -i -w "old string" "new string" test.txt test2.txt
Or even specify the extensions (
-x) to search or even search recursively (
-R) in the directory:
$ rpl -x .html -x .txt -R old_string new_string test*
You can also search/replace in interactive mode with
-p (prompt) option:
The output show the numbers of files/string replaced and the type of search (case in/sensitive, whole/partial words), but it can be silent with the
-q (quiet mode) option, or even more verbose, listing line numbers that contain matches of each file and directory with
-v (verbose mode) option.
Other options that are worth remembering are
-e (honor escapes) that allow
regular expressions, so you can search also tabs (
\t), new lines (
\n),etc. Even you can use
-f to force permissions (of course, only when the user have write permissions) and
-d to preserve the modification times`).
Finally, if you are unsure of which will make exactly, use the
-s (simulate mode).