a *very* odd question especially for me. Janina Sajka <janina at rednote.net> wrote
Tim Chase
blinux.list at thechases.com
Fri Jul 31 11:45:34 UTC 2015
On July 31, 2015, Tony Baechler wrote:
> To directly answer your question, bash tries to process each word
> of the filename separately, even when you put them in quotes, at
> least in a for loop. If you manually process one at a time, it
> works fine. I don't know why it doesn't work in a for loop even
> with quoting the filename, but it doesn't. You have to tell bash
> to not treat space as a separator.
It's a matter of what is doing the expanding. If you do
for f in * ; do echo "$f" ; done
it should work fine, mimicking "ls". The "*" expands once, giving
one "f" value for each file in input. Then when referencing it, you
have to make sure that you quote the variable as well, or your
command(s) will see that value split on white-space, rather than the
entire value.
-tim
More information about the Blinux-list
mailing list