[clug] Help with bash script

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

Brett Worth said:
=>Alastair D'Silva wrote:
=>>> Well one thing to do as a start is this: (to take care of spaces).
=>>>   mv "${file}" ${i}
=>> 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.
=>Not my bash:
=>[dart] touch a
=>[dart] touch "b b"
=>[dart] touch "c c c"
=>[dart] for F in *
=>> do
=>> ls -l "$F"
=>> done
=>-rw-r--r-- 1 brettw users 0 2008-11-01 20:52 a
=>-rw-r--r-- 1 brettw users 0 2008-11-01 20:52 b b
=>-rw-r--r-- 1 brettw users 0 2008-11-01 20:53 c c c

Yep, but if you're me and you're a bit soft in the head you think bash* will
be consistent:

for F in $(ls); do echo "$F"; done
prompt $

But you forget that's what it's going to do so can't see the massive bug in
the middle of a script where you want this stuff to work every time.

For my birthday I got a humidifier and a de-humidifier...  I put them in
the same room and let them fight it out.
		-- Steven Wright

More information about the linux mailing list