[Leaplist] teach me please about this code

Steve Litt slitt at troubleshooters.com
Fri Jan 4 16:22:01 GMT 2008


On Thursday 03 January 2008 19:51, tonyb wrote:
> The easy way to understand it is by using echo to display the
> interesting pieces:
>
> I needed to create some m4a files:
>
> touch aa.m4a bb.m4a cc.m4a
>
> Now for the echo statements:
>
> for i in *.m4a
> do
>   echo "$i"
>   echo "${i%m4a}mp3"
> done

Thanks Tony!

I've always used sed to rename, but this syntax is shorter and easier to 
remember.

And just for fun, here's one that converts ANY file to a .steve file:

for i in *
do
	echo $i
	echo ${i%.*}.steve
done

This even works with files not containing a dot.

SteveT



More information about the Leaplist mailing list