Monday, June 30, 2008

use shell variables in sed


input=abc.wav
i=0
while test $i != 10
do
echo "run case $i
tag=`expr output-foo-$i`
output=`echo $input | sed -e "s/^\(.*\)\.wav$/\1-$tag\.wav"`
./foo.bin -v -e -E $i -o $output $input
done


Here instead of

sed -e 's/^\(.*\)\.wav$/\1-$tag\.wav'


Use


sed -e "s/^\(.*\)\.wav$/\1-$tag\.wav"