[Perl] Question
Gabor Szabo
gabor at tracert.com
Tue Jun 4 08:19:07 PDT 2002
On Tue, 4 Jun 2002, Einat Wizeman wrote:
> >
> I would like to know how can I replace one string to another in a
> file
>
>
> For example:
>
> Temp.c -----> Temp.c
>
> Print "Einat"; Print "Shalom";
>
>
If this is a stand-alone change (that is not part of a bigger program)
then you can use the following:
perl -i -p -e 's/Einat/Shalom/g' Temp.c
though maybe you need a more specilized pattern
perl -i -p -e 's/Print "Einat";/Print "Shalom";/g'
and if you want to create backup with a .bak extension for the
original file then use
perl -i.bak ....
and if you are on windows then you are bit out of luck as you'll
have to replace ' by " and your'll have to escape the internal "
characters by \"
see more information in perldoc perlrun
reagrds
-- Gabor
More information about the Perl
mailing list