title: Storing Bash associative arrays
body: <p>I want to store (and retrieve, of course) Bash's associative arrays and am looking for a simple way to do that.</p>
  
  <p>I know that it is possible to do it using a look over all keys:</p>
  
  <pre><code>for key in "${!arr[@]}"
  do
    echo "$key ${arr[$key]}"
  done
  </code></pre>
  
  <p>Retrieving it could also be done in a loop:</p>
  
  <pre><code>declare -A arr
  while read key value
  do
    arr[$key]=$value
  done &lt; store
  </code></pre>
  
  <p>But I also see that <code>set</code> will print a version of the array in this style:</p>
  
  <pre><code>arr=([key1]="value1" [key2]="value2" )
  </code></pre>
  
  <p>(Unfortunately along with all other shell variables.)</p>
  
  <p>Is there a simpler way for storing and retrieving an associative array than my proposed loop?</p>