I've got a file test.tmp, and the file has the following content.
AAA 100
BBB 200
CCC 300
I'd like to create an associated array to save this information, so the key value pair would be
[AAA]=100, [BBB],200...
the code in the following is what I tried though it didn't work:
declare -A index
while read line
do
index[`echo $line | awk '{print $1}']=`echo $line | awk '{print $2}'`)
done < test.tmp
This is the code I used to check the array
for i in ${!index[@]}
do
echo "index $i: ${index[i]}"
done