Hi, I hope it's OK to ask questions here (the Gnu Bash FAQ seems to say
it's OK).

Values in the variable $@ can be extracted in a for loop in a way to
preserve individual strings that may have white space. For example:

        #!/bin/bash
        for x in "$@" ; do
                echo $x
        done

When called as ./doit a "b c" d
the output is

        a
        b c
        d

Is there a way to a similar for loop that processes a variable other than
$@ in the same way? For example:

        XXX='a "b c" d'
        for x in $XXX ; do
                echo $x
        done

That does not work as desired, nor does putting "$XXX" within quotes do
the trick (obviously). Is there a way?

Bob
_______________________________________________
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash

Reply via email to