Re: Handle each file at a time in loop?
On Tue, Jan 05, 2010 at 02:00:31AM +0530, Foss User wrote:
> $ ls
> convert.sh Track 1.wav Track 3.wav Track 5.wav Track 7.wav Track 9.wav
> Track 1.mp3 Track 2.wav Track 4.wav Track 6.wav Track 8.wav
> So, you can see there are file names with spaces in them. I have
> written a script like this to handle one file name at a time.
> for file in `ls *.wav`
> echo $file
> Of course, this doesn't do what I need. The names are split wherever
> there are spaces.
The ls is a totally unnecessary extra process and is what is causing
for file in *.wav
The quote marks around the variable ensure it is treated as a unit even
if it contains spaces.
The demands of the socialists raise another question, which I have
often addressed to them, and to which, as far as I know, they have
never replied. Since the natural inclinations of mankind are so
evil that its liberty must be taken away, how is it that the
inclinations of the socialists are good? Are not the legislators
and their agents part of the human race? Do they believe
themselves moulded from another clay than the rest of mankind?
-- Frédéric Bastiat (1801-1850)
Rick Pasotto firstname.lastname@example.org http://www.niof.net