I posted this in the Sed/Awk forum yesterday and wound up completely confused and couldn't get it working. I'm now wondering if sed is really what I need for this. Here's what I'm trying to do:
I have an xml file called playlist.xml the contents look like this:
Code:
charset utf-8
<xml>
<track>
<path>http://urlofsite.com/test2.mp3</path>
<title>01-07-10 - First Show of the New Year!</title>
</track>
<track>
<path>http://urlofsite.com/test1.mp3</path>
<title>12-25-09 - Christmas Special!</title>
</track>
</xml>
I am trying to write a script that asks the user what the path is and what the title is and then writes the necessary change to the xml file. The changes have to start on line 3 of playlist.xml. The script so far looks like this:
Code:
#!/bin/bash
xmlpath=../shows/playlist.xml
read -p "What is the path of the show? " showpath;
read -p "What is the title of the show? " showtitle;
sed -i 3i\
'\<track>\<path>'"$showpath"'\</path>\</title>'"$showtitle"'\</title>\</track>' $xmlpath
cat $xmlpath;
When I run this, it asks the questions and takes my input, but then I get an error saying that -i is an invalid option for sed. Do I need sed for this? Is there another way to do it? Any help would be much appreciated!