regex - Perl search and replace NOT working -
i trying replace string in file procedure seems removing string , not replacing want
example
perl -ne 'print unless s/serverip=${solid.host}/ads/;' needstobereplaced.prp > blah.txt
will remove
"serverip=${solid.host}" , leave line blank instead of printing "ads" in place
i running in windows way. have no 3rd parameter in regex because want change first occurrence. have tried
perl -pi -e 's/serverport=${solid.port}/ads/;' needstobereplaced.txt
but permission errors editing in place no go
you print line if substitution not successful. if want print always, not use unless
:
perl -pe "s/serverip=\${solid.host}/ads/;" needstobereplaced.prp > blah.txt
you should escape dollar sign prevent interpretation perl.
also note double quotes must used on ms windows.
Comments
Post a Comment