Re: bash scripting question
From: Floyd Davidson (floyd_at_barrow.com)
Date: 09 Aug 2003 22:39:47 -0800
Francisco <firstname.lastname@example.org> wrote:
>Say I want to decode with lame a lot of files in one dir, I do the
>for n in `ls *.mp3`;do lame --decode $n; done
>This works great if files dont have spaces, but if there are spaces the
>scripts fails because $n cantains only the fragment of the files names
>until a space occur.
>So, is there a solution to this?, how should I do it?
Put double quotes around $n
for n in `ls *.mp3`; do lame --decode "$n"; done
However, there is no need to use ls as you have, just do
for n in *.mp3; do lame --decode "$n"; done
Someone suggested using find, which will certainly work too. It
isn't needed unless you want to recurse sub directories or if
any of your files are "dot" files, like .hidden.mp3 which will
not be picked up using *.
-- Floyd L. Davidson <http://web.newsguy.com/floyd_davidson> Ukpeagvik (Barrow, Alaska) email@example.com