June 11, 2002

Edit HTML With a One-Line

Edit HTML With a One-Line Perl Program

I found this by googling for (no quotes) "perl one liner edit in place". It's handy.

Ah, found out one trickiness on Windows. Since the windows shell doesn't expand out globs like unix shells do, the example:

perl -i.bak -p -e 's/xyz\.rice\.edu/abc.rice.edu/ig' *.html

doesn't work. What you need to do instead is:

for %i in (*.html) do perl -i.bak -p -e 's/xyz\.rice\.edu/abc.rice.edu/ig' %i

You end up restarting perl every time (rather than one invocation over multiple files, you have multiple invocations on 1 file each), but it does work.

Posted by jshare at June 11, 2002 04:49 PM

Comments
Post a comment









Remember personal info?