I have a file with content:
( [datname]=template1 [datctype]=cs_CZ.utf-8 ) ( [datname]=template0 [datctype]=cs_CZ.utf-8 ) ( [datname]=postgres [datctype]=cs_CZ.utf-8 ) ( [datname]=some\ stupid\ name [datctype]=cs_CZ.utf-8 ) ( [datname]=jqerqwer,\ werwer [datctype]=cs_CZ.utf-8 )
I would read each line and click context on an associative array variable. I have no success in the following code:
(cat <<EOF ( [datname]=template1 [datctype]=cs_CZ.utf-8) ( [datname]=template0 [datctype]=cs_CZ.utf-8 ) EOF ) | while read r do declare -A row=("$r") echo ${row[datname]} done;
I got an error:
test3.sh: line 8: row: ( [datname]=template1 [datctype]=cs_CZ.utf-8 ): must use subscript when assigning associative array
Is it possible to read an array from a file?
source share