edit XML file using variable in shell script.

jc6


Joined
Feb 1, 2009
Messages
2
Reaction score
0
Points
1
Hi,

I am trying to edit a XML file using a shell script, but having some issues. Any help would be great.

I would like to edit the following string in a XML file that will be copied to a computer using a shell script.

When the file is copied to the machine, the value will have the following:
<key>UserName</key>
<string>host/computer.mydomain.com</string>

I would like to use a variable I have created in the shell script $COMPUTERNAME when changing the value. Below would be the desired output

<key>UserName</key>
<string>host/$COMPUTERNAME.mydomain.com</string>

Any ideas or suggestions would ge great.
 
OP
J

jc6


Joined
Feb 1, 2009
Messages
2
Reaction score
0
Points
1
Thanks guys, i was able to figure it out.. This seems to work.
sed "s/computer/$COMPUTERNAME/" /test.xml > /test2.xml
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top