[clug] Help with bash script

Hal Ashburner hal.ashburner at gmail.com
Sat Nov 1 09:58:55 GMT 2008


Alastair D'Silva said:
=>
=>Not quite everything you need . . . the for loop will still get tripped up
=>on spaces. Shell expansion will expand the wildcard into a space separated
=>list of files, which for will then split on spaces.

I quite like:

ls *.mp3|while read mp3file
do
    whatever_to $mp3file
done

In fact I even have been known to use that with find to avoid the
syntactic ugliness* of find -name '*.mp3' -exec whatever_to {}\;
And it works well in where the whatever_to is a few lines and you
don't want to write separate script for it when you're doing a slightly
inaccurately named "one liner."

*Personal taste, if you disagree then you are correct, no need to point it 
out.  ;)

-- 
'Scuse me, while I kiss the sky!
		-- Robert James Marshall (Jimi) Hendrix


More information about the linux mailing list