Note: You are viewing an old revision of this page. View the current version.
bash 4.x has associative arrays (hashes if you are an old perl user like me). The existing examples of how to use them on the internet are kind of garbage.
example 1: use a while/read loop to process a file line by line
while read line; do foo=awk blah bar=awk blarg done < file.txt
example 2: same, but process the contents of a multiline variable:
while read line; do foo=awk blah bar=awk blarg done <<< $data
turn those in to hashes, demonstrate how to manipulate them.
explain that bang means 'hash key' and no bang means 'hash value'.
need to also write up an example of mapfile
apologize profusely for doing all this.