ramk
1
Hello All,
I have the following lines in a file
<address location="test"
ConnectionName="test" />
I want to replace the above lines by
<address location="test123" />
I am usind SED and not able to remove the new line characters between the two lines.
Can anyone please help me.
Thanks
Ram
sed '/<address location="test"/{N;s/=.*/"test123" \/>/;}' file
ramk
3
Hi,
Thanks for the reply, the pattern worked for the lines but its not working fir more than 2 lines. For example, if my input is
<address location="test"
ConnectionName="test"
ConnectionFactory="m1234"
UserName="xyz" />
in this case also i want to get the output as
<address location="test123" />
Thanks
Ram
[root@rhnserver ~]# cat filem
<address location="test"
ConnectionName="test" />
[root@rhnserver ~]# sed '/address/{N; s/\(.*\)location=\"test\".*/\1location=\"test123">/ ; } ' filem
<address location="test123">
---------- Post updated at 11:02 PM ---------- Previous update was at 10:55 PM ----------
[root@rhnserver ~]# cat filem
<address location="test"
ConnectionName="test"
ConnectionFactory="m1234"
UserName="xyz" />
[root@rhnserver ~]#sed -n '/address/,/UserName/ {;/address/ s/test/test123 \/>/p} ' filem
<address location="test123 />"
sed -e '/<address location="test"/,/\/>/{/<address location="test"/s/"test"/"test123" \/>/;/<address location/!d;}' file