Monday, September 07, 2009

SED-insert quotes symbol

SED (stream editor) is a program to replace text in a file. Its easier to use VI, but sometimes, VI program is not available. Like in my case, I logged into z/Linux Server from Mainframe z/VM panel. I cant login remotely via SSH because network conf file (/etc/sysconfig/network/ifcfg-qeth*) is missing an important " symbol.

IPADDR="192.168.1.233

Typical SED command. Example to change ip from .233 to .234
sed -i ifcfg-qeth* -e 's/233/234/g'

but to add symbol " will not work straight away because ' and " is part of SED input.

Solution : use " twice, like this.
sed -i ifcfg-qeth* -e 's/233/234""/g'

Result :
IPADDR="192.168.1.234"


Thanks to Wan Uni Azran for helping me figure this out!

2 Comments:

Blogger RayRosli Abas said...

zvm reference
http://publib.boulder.ibm.com/infocenter/zvm/v5r3/index.jsp?topic=/com.ibm.zvm.v53.hcpa2/diis4.htm

4:24 PM  
Blogger rayrosliabas said...

delete a line using sed. example line no 5.

cat -n myfile.txt
sed 'd5' myfile.txt

1:56 AM  

Post a Comment

<< Home