[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: shell script question



On Mon, 13 Oct 2003 08:30:23 +0100 Colin Watson wrote:
> On Sun, Oct 12, 2003 at 11:18:11PM -0400, Jeff Elkins wrote:
> > mpg123 -b 10000 -s "$1" | sox -t raw -r 44100 -s -w -c2 - "$2"
> > 
> > In every case, $1 and $2 are the same, except for $2 I want the output
> > filename to have a .wav extension.
> > 
> > Could I alter the script to eliminate entering $2, since the basic filename is 
> > the same?
> 
> Here's a little expression that strips off any trailing ".<extension>"
> from $1 and tacks on ".wav".
> 
>   "${1%.*}.wav"

That's much better, no dependency on yet another utility, so more portable
code.

-- 
Carlos Sousa
http://vbc.dyndns.org/



Reply to: