value to great for base error from bash associative array -
i have file called a.txt looks follow
7a1123123asd 14 8aasdasdasd 15
now wrote bash code read file , build associative array values in it
#!/bin/bash declare -a counter while read deal count; counter["$deal"]=$count done < oasload.job in "${!array[@]}" echo "key : $i" echo "value : ${array[$i]}" done
unfortunately when run following error
test.sh: line 6: 7a1123123asd: value great base (error token "7a1123123asd")
any appreciated.
looks bash treats keys starting digits numeric. so, trying convert 7a balks because not valid base-10 digit. if can e.g. prefix keys x throughout, should fix it.
#!/bin/bash declare -a counter while read deal count; counter["x$deal"]=$count done < oasload.job in "${!array[@]}" echo "key : $i" echo "value : ${array[$i]}" done
Comments
Post a Comment