Using the -p switch and a positive look-behind will save some typing. I also prefer the safety net of in-place editing with the -i switch.
$ cat test.sh some stuff export SERVING_GW_ADDR=47.104.153.103 export TEMP_SGW_PDP_ADDR=47.104.153.103 more stuff $ perl -pi.BAK -e ' > s/(?<=TEMP_SGW_PDP_ADDR=).*$/47.104.153.163/;' test.sh $ head -99 test.sh* ==> test.sh <== some stuff export SERVING_GW_ADDR=47.104.153.103 export TEMP_SGW_PDP_ADDR=47.104.153.163 more stuff ==> test.sh.BAK <== some stuff export SERVING_GW_ADDR=47.104.153.103 export TEMP_SGW_PDP_ADDR=47.104.153.103 more stuff $
I hope this of interest.
Cheers,
JohnGG
In reply to Re^2: perl one line helper
by johngg
in thread perl one line helper
by vasista2k
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |