I have the following associative array.
var1="dog"
var2="cat"
var3="moose"
declare -A asar01=(
["one"]="$var1"
["two"]="$var2"
["three"]="$var3"
)
I want to loop through and print each values variable name. So only "var1", "var2" and "var3" will print. How can I accomplish this? I tried the following but it prints the actual scripts name. as the first variable output.
for i in "${!asar01[@]}";do
echo "${!asar01[$i]}"
done
My example is trying to use the ${!variable}
method to print the name but its not working.
How can I accomplish this?