Re: a *very* odd question especially for me. Janina Sajka <janina@xxxxxxxxxxx> wrote

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



_______________________________________________
Blinux-list mailing list
Blinux-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/blinux-list



[Index of Archives]     [Linux Speakup]     [Fedora]     [Linux Kernel]     [Yosemite News]     [Big List of Linux Books]