Reputation: 483
we set the "list" variable with sdb - sdz range
# MAX=z
# list=$(eval echo sd{b..$MAX})
# echo $list
sdb sdc sdd sde sdf sdg sdh sdi sdj sdk sdl sdm sdn sdo sdp sdq sdr sds sdt sdu sdv sdw sdx sdy sdz
until now its ok
now we set the $list in array as the follwing
#array=( echo $list )
but when we print the first value of the array we get "echo"
#echo ${array[0]}
echo
what is wrong here?
expected results:
#echo ${array[0]}
sdb
#echo ${array[1]}
sdc
#echo ${array[2]}
sdc
or
# echo "${list[counter++]}"
Upvotes: 0
Views: 354
Reputation: 7509
$ max=z
$ list=( $(eval echo sd{b..$max}) )
$ echo "${list[*]}"
sdb sdc sdd sde sdf sdg sdh sdi sdj sdk sdl sdm sdn sdo sdp sdq sdr sds sdt sdu sdv sdw sdx sdy sdz
$ echo "${list[1]}"
sdc
Upvotes: 1