Sample Header Ad - 728x90

Associative Arrays in Shell Scripts

13 votes
4 answers
44445 views
I saw a trick for implementing associative arrays in a shell script. For example print array["apples"] could be scripted as echo \$array$key where key=apples. However, there was no mention of how to generate the keys to iterate over the array. The only way I could think of was to store the keys in a variable delimited by spaces so I could use a for-loop to iterate over the array. So, is there some other way to store the keys for later use?
Asked by EggHead (275 rep)
Jan 28, 2014, 10:35 PM
Last activity: Feb 20, 2024, 10:14 PM