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

[ale] Keep space separated values sane in a bash "for" loop?



If you are using ls you could try looking into the Q option. It
double-quotes
the output.

ls -Q

Best regards,

J. D.

On 4/5/07, Christopher Bergeron <christopher at bergeron.com> wrote:
>
> Guys, I'm not sure how to word my question appropriately, so I'll try to
> explain what I'm trying to do in code.
>
> I have a bash for loop, and when it encounters a value with a space, it
> splits it into separate entities.  For example:
>
> With a file list of:
> /bin
> /usr
> /Virtual Machines
>
> and a code snippet of:
>
> for i in *; do
> echo "Filename is: $i"
> done
>
> The output is:
>
> Filename is: bin
> Filename is: usr
> Filename is: Virtual
> Filename is: Machines
>
> How can I tell bash to keep these values together, so that I get the
> filenames intact as:
> Filename is: bin
> Filename is: usr
> Filename is: Virtual Machines
>
> Thanks in advance...
>
> Kind regards,
> Chris Bergeron
> http://chrisbergeron.com
>
>
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://www.ale.org/mailman/listinfo/ale
>
-------------- next part --------------
An HTML attachment was scrubbed...