[Ilugc] perl find-replace

  • From: carti@xxxxxxxxxxxxxx (carti)
  • Date: Tue Jul 20 13:48:36 2004


Hi,

I need to find and replace a string(regular
expression) in a file.

Is there anyway to do in shell programming.
(I dont want to use sed).

Also, I saw acommand line option in perl.
It is as follows
perl -pi -e 's/findtext/replacetext/g' myinput.txt

This works well with perl in unix environment.

But in windows environment, perl gives the error message
saying that,
"Can't do inplace edit without backup".

I searched in google for this, and was told that the option

perl -pi.bak -e 's/findtext/replacetext/g' myinput.txt
will work out.

I tried with that.
Still it does, not work. It just copies the original file
in the name myinput.txt.bak.

If anybody has a solution, please tell me..

Thanks and regards,
carti

Other related posts:

  • » [Ilugc] perl find-replace - carti