Perl search and replace string. I use the following script to replace all occurrences of oldstring with newstring in all of the files in your current directory.
perl -p -i -e 's/oldstring/newstring/g' *
How do I replace in sub-directories as well?
Use Perl and Find as following. Perl before find or find before perl doesn't matter.
perl -p -i -e 's/oldstring/newstring/g' `find ./ -name *.html`
or
find ./ -exec perl -p -i -e ’s/oldstring/newstring/g’ {} \;
Tony
<code>
<blockcode>
<c>
<cpp>
<drupal5>
<drupal6>
<java>
<javascript>
<php>
<python>
<ruby>
<foo>
[foo]
Use Perl and Find as following. Perl before find or find before perl doesn't matter.
or
find ./ -exec perl -p -i -e ’s/oldstring/newstring/g’ {} \;Tony
Post Comment