[CentOS] replace

Phil Schaffner Philip.R.Schaffner at NASA.gov
Fri Oct 24 20:58:42 UTC 2008


Mad Unix wrote:
> i need your feedback about this command, it should find a string in
> multiple html files in a directory and replace it with a different
> string...
> 
> find /dir -name "*.html" -exec sed -i 's/"old"/"new"/g' {} \;

Mad Unix,

find /dir -name "*.html" -exec sed -i -e 's/old/new/g' {} \;

or

find /dir -name "*.html" -exec sed -i".bck" -e 's/old/new/g' {} \;

to keep a backup.

Phil



More information about the CentOS mailing list