Quote:
Originally Posted by vivo2341
so it would be 'find /home/vivo2341 -name \*.html | xargs perl -wi- -pe 's/a/1234/5678/g'
Like that? I just don't want to screw up everything and ruin something, I will do a backup and then try this tonight! Thank you both for your help.
|
Close. With the italic
a I was referring to your original question, asking to replace word "a". So substitute "1234" for the [i]a[/a]; the command line should be
Code:
find /home/vivo2341 -name \*.html | xargs perl -wi~ -pe 's/1234/5678/g'
You could also specify the four options separately to make clearer what's going on -- "perl -w -i~ -p -e 's/1234/5678/g'" (the single quotes are unnecessary here, but a good practice in general).
The perl option
-i~ (that's i tilde) does the processing
in place, and writes a backup to a file with a tilde appended. E.g., if a file foo.html is changed, you'll find the original version in foo.html~. I chose "~" to be compatible with emacs. That said, making a backup of the whole site is probably a good idea; it may be quicker to revert if something does go wrong.
To check beforehand what command line(s) will be executed, you could change "perl" to "echo perl" -- that way you'll see the (long!) command line(s) without running them.
To check afterward if it worked right, "diff foo.html{~,}" (replacing a real file name for "foo".
Be aware that, e.g., 2.5123489 will be changed to 2.5567889. If that's not desirable, tell us a bit more about which occurrences of "1234" you want to replace. Most constraints can be written as a regular expression (which we use in the
s command).
Now there's more than you ever wanted to know