HowTo to perform a search and replace on a text file
Author:  Darrell May
Contributor:  jason (jblakey@frogboy.net)

Problem:  You want to perform a search and replace on a text file.

Solution:  Here is a perl command I received from a post on the Experienced User Forum.  Thanks Jason :->

<http://www.e-smith.org/bboard/read.php?f=3&i=7962&t=7892>


In the example shown below I want to open the file named /root/test.txt, search for the word e-smith and replace it with the word mitel.  In addition, the command creates a backup of the original file with the extension .bkup.  In this case it creates /root/test.txt.bkup.

perl -n -i.bkup -e 's/e-smith/mitel/i; print;' /root/test.txt