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

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -