Saturday, April 25, 2015

Replace a string in several files

[CONTEXT]
You need to replace a string in several files

[HOW]
There several options to do this, 
  • sed:         Syntax:    $ sed -i "s/old_string/new_string/g" files
                    Example  $ sed -i "s/foo/bar/g" *.txt 
  • perl:       Syntax:    $ perl -i -p -e "s/old_string/new_string/g;" files  
                        


[SOURCE]
sed man page 
http://www.cyberciti.biz/faq/unix-linux-replace-string-words-in-many-files/