Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

loading array from environment variable 1

Status
Not open for further replies.

jbonin

Programmer
Mar 25, 2002
11
0
0
US
I have a problem loading an array from a variable containing
quotes and spaces, but interactively without a variable works fine. Here is the reproducible problem. I want the
array vararray to have the same element values as tarray,
but as you can see, when loading the same data from a
variable, it splits all the words for all the values into
separate elements of the array vararray.

Thanks for any help!

John

echo '"one two three four" "five six seven eight" "nine ten eleven"'
set -A tarray "one two three four" "five six seven eight" "nine ten eleven"
echo ${tarray[0]}
echo ${tarray[1]}
echo ${tarray[2]}
zarray='"one two three four" "five six seven eight" "nine ten eleven"'
echo $zarray
set -A vararray ${zarray}
echo ${vararray[0]}
echo ${vararray[1]}
echo ${vararray[2]}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top