populate associative array from output bash code example
Example 1: populate associative array from output bash
$ declare -A arr=(); while read -r a b; do arr["$a"]="$b"; done < <(cmd)
Example 2: bash function to populate associative array
declare -a cols
while read num color; do
cols[$num]=$color
done < file.txt
for key in "${!cols[@]}"; do printf "%s\t%s\n" "$key" "${cols[$key]}"; done