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

Re: Strange variable asignement in bash script



Juan Sierra Pons wrote:
Hi guys
I want to do something like this;
for I in `echo $TEST`
 do
  for J in `echo $HOSTS`
   do
   .....
   .....
   .....
   $TEST.$HOST="some value"
  done
done

Please excuse me eliding all the helpful posts proposing solutions to the OP's
problem...

It is usually a bad idea to create arbitrary variable names based on 'data'[1].
ESPECIALLY in shell scripts. If you can explain why you believe you need to store
each result in a uniquely named variable, I think we could find a simpler way to
solve your problem.

Best regards,

    Blair.

--
[1] Unless you're a Lisper or you're SURE you know what you're doing.

Obligatory Lewis Carroll reference (I can't help it):

... "The name of the song is called 'Haddock's Eyes'."  "Oh, that's the name of the
song, is it?" Alice said, trying to feel interested.  "No, you don't understand," the
Knight said, looking a little vexed. "That's what the name is called. The name really
is 'The Aged Aged Man'."  "Then I ought to have said 'That's what the song is called?'"
Alice corrected herself.  "No, you oughtn't: that's quite another thing! The song is
called 'Ways and Means': but that's only what it's called, you know!"  "Well, what is
the song, then?" said Alice, who was by this time completely bewildered.  "I was coming
to that," the Knight said. "The song really is 'A-sitting on a Gate': and the tune's my
own invention."

Attachment: signature.asc
Description: OpenPGP digital signature


Reply to: