Hi,
Watael is on the right track, I would do it with a for loop thou.
Code:
#!/bin/bash
file=$1
IFS="
"
for i in $(cat $file); do
test_line=$(echo $i | cut -d' ' -f1)
case $test_line in
PERFORMER)
song[0]=$(echo $i | cut -d'"' -f2)
echo_it=0
;;
TITLE)
song[1]=$(echo $i | cut -d'"' -f2)
echo_it=1
;;
esac
if [ $echo_it -eq 1 ]; then
echo "${song[0]} - ${song[1]}.mp3";
run=0
fi
done
This might be somewhat easier to understand.
Basically what it does is looping throu using for and IFS (as you've done in your first post.).
IFS does not need to be reset if you're running it in a script, scripts run in it's own subshell so all exports gets unset when it exists.
Code:
sajko@hanna:~> cat demo.sh
#!/bin/bash
IFS="
"
sajko@hanna:~> sh demo.sh
sajko@hanna:~> echo \"$IFS\"
" "
Also, IFS doesn't always like \n... this is because there's so many ways of doing a carriage return... \r is another method or if you run windows \r\n.
To get back to the topic. $test_line just cut's out the first (-f1) "column" separated by a space character (-d' ' in the cut command).
Next we run it thru case since it's easier to pattern match and extend it imo

The next cut just cut's out everything beyond the first quotation mark until the next one.
Hope this gives you a clue

ps. If you chmod +x a script with a shebang then it will execute with that if it's runned with ./script.sh, this works for whatever executor you want to use (ex sh, perl, php and so on) ds.
Best regards
Fredrik Eriksson