Answers for "populate associative array from output bash"

0

populate associative array from output bash

$ declare -A arr=(); while read -r a b; do arr["$a"]="$b"; done < <(cmd)
Posted by: Guest on April-01-2021
0

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
Posted by: Guest on April-01-2021

Code answers related to "populate associative array from output bash"

Browse Popular Code Answers by Language