If the command output is in the file file , then:
$ declare -A arr=(); while read -rab; do arr["$a"]="$b"; done <file
Or you can read the data directly from the cmd command into an array as follows:
$ declare -A arr=(); while read -rab; do arr["$a"]="$b"; done < <(cmd)
The <(...) construct is a replacement for the process. This allows us to read from a command as if we were reading from a file. Note that the space between the two < significant.
You can verify that the data is read correctly with declare -p :
$ declare -p arr declare -A arr='([tank]="zfs" [/]="ext4" [/boot]="ext2" )'
John1024
source share