Hello fellow ladies and gentlemen, I haven't been doing this long, and here is my trouble:
First, I have a text file called songinfo, inside is listed song information in this format (one song per line):
song_name:album_name:artist_name:song_length:year
Next, I have a script that is eventually supposed to allow the user to modify any field in a song entry. This is after having isolated the song's line in the file. The next part could so far be summarized like:
_____________________________________________________
echo "Choose which attribute to edit: "
echo "A -- song name"
echo "B -- album name"
echo "C -- artist name"
echo "D -- year"
echo
echo "Edit option: "
read change
case $change in
a|A)
oldsong=`cut -f 1 -d :`
echo -n "Enter new song name: "
read newsong
sed w s/$oldsong/$newsong/ songinfo
;;
b|B)
oldalbum=`cut -f 2 -d :`
echo -n "Enter new album name: "
read newalbum
sed w s/$oldalbum/$newalbum/ songinfo
;;
...and so on
___________________________________________________
My question is how do I properly user sed to replace the field in the songinfo from the old value to the new value? I don't know if I'm misusing sed, or the variables even.
As of now, the output is that there is no visible change after execution, and if I check the songinfo file, the text will now have changed.
Please and thanks in advance