Perl Search & Replace One-Liner
Yes, it’s been used for a long long time and I have been using them for quite a while too. But the problem is, I always forget which one to leave out for a dry run.
For search and replace applied to files specified:
me@mycomp:~$ perl -pi -e ‘s/search/replace/g’ *.html
For non-applied search and replace (without the i argument):
me@mycomp:~$ perl -p -e ‘s/search/replace/g’ something.html
The way I try to use now to remember which one to exclude is this:
-pi means print into as in print into the file(s) searched and p means print only [to screen].
Have fun!