i have such bash code below, want know how find array it's name:
#!/bin/bash arr=("object1" "object2") name="arr" array=${!name} echo object0 = ${array[0]} echo object1 = ${array[1]}
outputs below:
object0 = object1 object1 =
i'm wondering why cannot index second element , how can that!!!
use syntax:
name="arr[@]" array=("${!name}")
your other code fine.
or if have passed variable, name="arr"
you can use hack:
name_temp="$name[@]" array=("${!name_temp}")
Comments
Post a Comment