Skip to main content
added 19 characters in body
Source Link
choroba
  • 49.6k
  • 7
  • 92
  • 119

Include the index"index", i.e. the [@], in the variable that contains the name:

ref=$gral'[@]'
echoprintf '%s\n' "${!ref}"

Output:

milk
cow
budgie
pla9ne

It works with values containing spaces, too.

Include the index in the variable that contains the name:

ref=$gral'[@]'
echo "${!ref}"

Include the "index", i.e. the [@], in the variable that contains the name:

ref=$gral'[@]'
printf '%s\n' "${!ref}"

Output:

milk
cow
budgie
pla9ne

It works with values containing spaces, too.

Source Link
choroba
  • 49.6k
  • 7
  • 92
  • 119

Include the index in the variable that contains the name:

ref=$gral'[@]'
echo "${!ref}"