I have a sed command I wish to run from within a bash script on a large xml
file.
sed -i '/$OLD_IP_ADDRESS/!{q100}; {s/$OLD_GATEWAY/$NEW_GATEWAY/}' $system_file
where , if $OLD_IP_ADDRESS
is present I substitute $OLD_GATEWAY
for $NEW_GATEWAY
(IPs) but $OLD_IP_ADDRESS
if it is not present then I return 100
I am using the following from
Return code of sed for no match
as an example
kent$ echo "foo" | sed '/foo/!{q100}; {s/f/b/}'
boo
kent$ echo $?
0
However when I run the command it removes the entire body of the xml
and only leaves me with the header line
I have tried numerous variations of this but don't understand/see where I'm blanking the file.
I have searched but cant find info on this so any help would be most appreciated.