[Techtalk] Question: sed s option in a shell script
Sabine Konhaeuser
sjmk at gmx.net
Mon Mar 14 15:41:30 EST 2005
Hi Everyone,
I'm in the process of digitizing my record collection. I will save the
recorded songs as flac and mp3 files. The flac command flac -8 *.wav
loops through the entire directory and creates the flac files. So far
so good. Lame however doesn't seem to do this. So I wrote a small
script that loops through the directory, fetching every wav file and
then with sed replace the ending wav with mp3. This is the script:
**** script starts here ****
OLDSUFFIX=wav
NEWSUFFIX=mp3
for FILE in *."$OLDSUFFIX"
do
NEWNAME=´"$FILE" | sed -e "s/$OLDSUFFIX/$NEWSUFFIX/"´
lame --preset standard "$FILE" "$NEWNAME"
done
**** script ends here ****
I tried different variations: extensions instead of variables, single
quotes instead of double quotes, g at the end, .wav and .mp3 instead
of the version without the ., but always the same error message:
sed: -e expression #1, char 11: unknown option to `s'
(char 11 varies depending what I change in the s part.)
I'm not sure what's wrong here (not much of a shell scripter).
According to the man and info pages the syntax seems to be correct.
Maybe someone can help? I use:
GNU sed version 4.1.2
GNU bash, version 3.00.0(1)-release (i586-suse-linux)
SuSE 9.2
The script itself does work, it loops through all the wav files and
creates the mp3 files. But the file name is not file_name.mp3 but
file_name.wav.mp3. Not that this is a big deal, but the wav in the
name bothers me and I'd like to have it removed automatically. Right
now I rename the files by hand.
Any help or tip will be welcome.
Cheers,
--
Sabine
More information about the Techtalk
mailing list