[Top][All Lists]

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

Re: Question about variables and for loop

From: Bob
Subject: Re: Question about variables and for loop
Date: Sun, 19 Mar 2006 03:02:51 GMT
User-agent: Pan/0.14.90 ('Ere, he says he's not dead.)

On Sat, 18 Mar 2006 20:44:17 -0500, Paul Jarc wrote:

> Bob <address@hidden> wrote:
>>      XXX='a "b c" d'
>>      for x in $XXX ; do
>>              echo $x
>>      done
> XXX='a "b c" d'
> eval "set $XXX"
> for x in "$@" ; do
>       echo $x
> done
> If the first element in XXX might start with "-", then it takes a little
> more work to ensure it isn't misinterpreted as an option to "set":
> eval "set x $XXX"
> shift
> paul

Great! That works. Unfortunately, the example I gave you was simplified
from my actual application (too big and confusing to post here). There is
another complication ... my variable has new-line characters embedded in
it so the "eval" above gets many invalid command errors. I need to replace
the new-lines with spaces. I will try the tr command.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]