[Gllug] A command to repeat a function for each file

tet at accucard.com tet at accucard.com
Fri Feb 15 10:03:11 UTC 2002


>	outfile=`echo $infile|cut -f1 -d"."'-11025.wav
>
> [...]
>
>Will not be happy file filenames with .'s (except to mark the
>extention) - I could fix these limitations, (with perl, to be the
>fastest, but I hate perl :) ) but I'm a fat lazy pig, and I like shell.

In fact, it won't be happy at all -- you used an apostrophe where you
meant to use a backquote...

But that aside, use sed rather than cut to solve your problem:

	outfile=`echo "$infile" | sed 's/.wav$/-11025.wav/'`

If you're using a POSIX compliant shell, you can achieve the same effect
with parameter substitution:

	outfile="${infile%.wav}-11025.wav"

Oh, and you'll want to quote "$infile" and "$outfile" when you dereference
them to call sox. Otherwise it'll fail with filenames containing whitespace.

Tet

-- 
Gllug mailing list  -  Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug




More information about the GLLUG mailing list