Please review the sample code setup for 3x3 2D associative Array matrix. and at the bottom I'm trying print all the elements from 2D bash associative array matrix... for e.g. all [args] keys... But I'm not getting what I needed... specific keys printed for e.g.: all [args] keys...
My bash version:
$ bash --version
GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu)
What am I missing?
declare -A assocArr
echo "Intialize the Associative Array (assocArr):"
assocArr[0,pid]=12345; assocArr[0,args]='/path/to/app/args'; assocArr[0,uptime]='4-2:50:35'
assocArr[1,pid]=56789; assocArr[1,args]='/path/to/app/args'; assocArr[1,uptime]='1-2:50:42'
assocArr[2,pid]=54321; assocArr[2,args]='/path/to/app2/args'; assocArr[2,uptime]='3-2:30:23'
echo "print the Associative Array (assocArr) elements:"
echo "assocArr[0,pid] is ${assocArr[0,pid]} ; assocArr[0,args] is ${assocArr[0,args]} ; assocArr[0,uptime] is ${assocArr[0,uptime]}"
echo "assocArr[1,pid] is ${assocArr[1,pid]} ; assocArr[1,args] is ${assocArr[1,args]} ; assocArr[1,uptime] is ${assocArr[1,uptime]}"
echo "assocArr[2,pid] is ${assocArr[2,pid]} ; assocArr[2,args] is ${assocArr[2,args]} ; assocArr[2,uptime] is ${assocArr[2,uptime]}"
echo "random element printing"
echo "${assocArr[1,args]}"
echo "PRINT ALL ELEMENTS of a SPECIFIC [key] for e.g.: all [args]"
echo "{assocArr[@,args]} :
${assocArr[@,args]}"
echo "{assocArr[@ args]} :
${assocArr[@ args]}"
echo "{assocArr[@][args]} :
${assocArr[@][args]}"