Use hash table in shell

Declare a hash array and assign:

Insert key-value pair or modify value by key:

Get keys and values by iterator:

You can use hash arrays just like normal arrays. “${animals[@]}” expands the values, “${!animals[@]}” (notice the !) expands the keys.

Reference: