Hi,
I'm working on a script to kill a current song being played by ogg123, and I have gotten as far as retrieving the location of the song.
It is stored in a text file (playlist) in this format:
Quote:
various_artists/wow_hits_2005_disc_2/never_alone__barlowgirl.ogg
|
That is also the format of the string that is stored in CURRENT_PLAYLIST once
Code:
CURRENT_SONG=`tail nohup.out | grep "Playing:" | cut -c 12-500`
is executed in the script.
I am able to get the current song without any trouble, but am not sure how to use sed to delete the current song from the playlist.
Here is the script (sed part is not working):
Code:
#!/bin/sh
# script to remove songs from a playlist and/or skip to the next song
####################################
# Variables
####################################
PLAYLIST_DIR="/music"
PLAYLIST="bedtime.playlist2"
DEBUG="1"
####################################
# Get the current playing song
####################################
# Change to root directory
cd /
CURRENT_SONG=`tail nohup.out | grep "Playing:" | cut -c 12-500`
if [ ${DEBUG} = "1" ]; then
echo ${CURRENT_SONG}
fi
# We now have the current song, let's remove it from the playlist.
if [ ${DEBUG} = "1" ]; then
echo Here is the sed command we are going to run: sed -e !\ ${CURRENT_SONG}!\d
fi
mv ${PLAYLIST_DIR}/${PLAYLIST} ${PLAYLIST_DIR}/${PLAYLIST}.$$
sed -e !\ ${CURRENT_SONG} !\d ${PLAYLIST_DIR}/${PLAYLIST}.$$ \
> ${PLAYLIST_DIR}/${PLAYLIST}
if [ ${DEBUG} = "1" ]; then
cat ${PLAYLIST_DIR}/${PLAYLIST}
fi
exit 0
I used \ \ around the expression, but now the variable is being used literallly instead of being replaced.
Help would be great, because sed is alien to me. Thanks.