Re: a *very* odd question especially for me. Janina Sajka <[email protected]> wrote

Tim Chase <[email protected]>
Newsgroups gmane.linux.redhat.blinux.general
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.