[clug] Help with bash script

Alastair D'Silva alastair at newmillennium.net.au
Sat Nov 1 10:49:18 GMT 2008


Thats pretty elegant, I like it.

Its funny, I've used read heaps of times before, but never thought to use it
to break out of the clunkiness of calling a second script. Thanks!

--
Alastair D'Silva           mob: 0423 762 819
Networking Consultant
New Millennium Networking  web: http://www.newmillennium.net.au
skype: alastair_dsilva     msn: alastair at d-silva.org
blog: http://alastair.d-silva.org


-----Original Message-----
From: linux-bounces+clug=d-silva.org at lists.samba.org
[mailto:linux-bounces+clug=d-silva.org at lists.samba.org] On Behalf Of Hal
Ashburner
Sent: Saturday, 1 November 2008 8:59 PM
To: Alastair D'Silva
Cc: 'CLUG List'
Subject: Re: [clug] Help with bash script

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
-- 
linux mailing list
linux at lists.samba.org
https://lists.samba.org/mailman/listinfo/linux




More information about the linux mailing list