Answers for "bash access array indirectly"

CSS
0

bash access array indirectly

#!/usr/bin/env bash

ARRAYNAME='FRUITS'
FRUITS=( APPLE BANANA ORANGE )

eval array=\( \${${ARRAYNAME}[@]} \)

for fruit in "${array[@]}"; do
  echo ${fruit}
done
Posted by: Guest on September-28-2020

Browse Popular Code Answers by Language