shell dict
#!/bin/bash result_file="a" declare -A mydict :>${result_file} total=`cat ${result_file}.bak| wc -l ` count=0 #function getdev() { #cat ${result_file}.bak | while read campid devid needmd5 while read campid devid needmd5 do #echo "$campid devid: $devid " if [ -z "${mydict[$devid]}" ]; then #echo "if $devide " #mydict=([$devid]=$campid) #export mydict+=([$devid]="$campid") echo "aaafter mydict keys ${!mydict[*]} " else #$mydict[$devid]+="," + $campid mydict+=([$devid]+=","$campid) fi ((count+=1)) if [ $count -eq $total ]; then echo "count : $count " echo "bbbfter mydict keys ${!mydict[*]} " fi echo "before return ${!mydict[*]} " done < ${result_file}.bak echo "before return ${!mydict[*]} " #} #echo "mydict $mydict " #echo ${!mydic[*]} echo "after mydict keys ${!mydict[*]} " echo "ccc $ccc " for key in $(echo ${!mydict[*]}) do echo " k: $key : ${mydict[$key]}" done