go ahead... be a heretic | |
PerlMonks |
Re: Can you teach a new dog an old trick?by Chady (Priest) |
on Jul 28, 2001 at 20:39 UTC ( [id://100567]=note: print w/replies, xml ) | Need Help?? |
perl -pi.bak -e "s/string1/string2/g" *
run this and it will open all files in the current directory with the inplace file edit -i and files are backed up to .bak extensions, the -p assumes that there is a while loop over the file so all you need to do is run the substitution within a -e switch and you're done with it. Update: I stole from jeffa's post that you should have *.htm instead of * so it won't eat all the files He who asks will be a fool for five minutes, but he who doesn't ask will remain a fool for life. Chady | http://chady.net/
In Section
Seekers of Perl Wisdom
|
|