Issue
We require a script that simulates associative arrays or map-like data structure for shell scripting. Can anyone let's know how it is done?
Solution
To add to Irfan's answer, here is a shorter and faster version of get()
since it requires no iteration over the map contents:
get() {
mapName=$1; key=$2
map=${!mapName}
value="$(echo $map |sed -e "s/.*--${key}=\([^ ]*\).*/\1/" -e 's/:SP:/ /g' )"
}
Answered By - Jerry Penner Answer Checked By - Marie Seifert (WPSolving Admin)