Storing Bash Associative Arrays -
Storing Bash Associative Arrays -
i want store (and retrieve, of course) bash's associative arrays , looking simple way that.
i know possible using on keys:
for key in "${!arr[@]}" echo "$key ${arr[$key]}" done
retrieving done in loop:
declare -a arr while read key value arr[$key]=$value done < store
but see set
print version of array in style:
arr=([key1]="value1" [key2]="value2" )
(unfortunately along other shell variables.)
is there simpler way storing , retrieving associative array proposed loop?
to save file:
declare -p arr > saved.sh
(you can utilize typeset
instead of declare
if prefer.)
to load file:
source saved.sh
arrays bash associative-array data-retrieval storing-information
Comments
Post a Comment