Results 1 to 2 of 2
  1. #1


    Member Since
    Feb 01, 2009
    Posts
    2
    edit XML file using variable in shell script.
    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.

  2. #2


    Member Since
    Feb 01, 2009
    Posts
    2
    Thanks guys, i was able to figure it out.. This seems to work.
    sed "s/computer/$COMPUTERNAME/" /test.xml > /test2.xml

Thread Information

Users Browsing this Thread

There are currently 2 users browsing this thread. (0 members and 2 guests)

Similar Threads

  1. How to edit PATH variable outside of terminal
    By oxy126 in forum OS X - Operating System
    Replies: 4
    Last Post: 04-22-2011, 06:29 PM
  2. Run shell script from a pkg file
    By nitingpt in forum OS X - Apps and Games
    Replies: 0
    Last Post: 02-09-2011, 06:38 AM
  3. Terminal -- shell script -- script will only read two lines of a file
    By Straitsfan in forum OS X - Apps and Games
    Replies: 0
    Last Post: 01-30-2011, 09:04 PM
  4. shell script improperly converts variable name to string as an argument.
    By Onikaji in forum OS X - Development and Darwin
    Replies: 0
    Last Post: 12-18-2009, 02:43 PM
  5. shell script xml
    By MrGecko in forum OS X - Development and Darwin
    Replies: 4
    Last Post: 10-03-2006, 07:44 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •