views:

25

answers:

1

Hello,

I'm not sure how to do this but I figured I would ask here.. I'm trying to create a string of specific environment variables such that:

$A = "foo" $B = "bar" $C = "baz"

would give "foo, bar, baz"

Unfortunately, it doesn't seem that the Bourne shell supports arrays, which would have made these easily solvable. The other way I'm trying to solve this is by directly inserting my own variable called $COMMA after each environment variable, however I am getting syntax errors so I'm not sure how to do this correctly. Would appreciate any advice here, thanks!

+1  A: 

Your variables shouldn't start with $ unless you want the value of them (this isn't perl or php...)

 A=foo
 B=bar
 C=baz

 echo $A,$B,$C

or even:

 A=foo B=bar C=baz echo $A,$B,$C

will give you a comma seperated list of the variables you defined.

Burton Samograd