Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^2: perl one line helper

by johngg (Canon)
on Dec 07, 2009 at 16:32 UTC ( [id://811540]=note: print w/replies, xml ) Need Help??


in reply to Re: perl one line helper
in thread perl one line helper

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://811540]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (2)
As of 2024-04-26 00:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found