I've been trying to storage my data in an array as follows:
table="$1"
reference="$2"
directory="$3"
declare -A count
$reference | while read line; do
ref=`echo $line | cut -d " " -f1`
key=`echo $line | cut -d " " -f4`
count=([$key]=$ref)
echo $ref
echo $key
echo "${count[$key]}"
done
This works, I do the prints and for each key I got the value I want. Then, I try to use with some keys:
cat $table | while read line; do
sample=`echo $line | cut -d "_" -f1`
id=${count[$line]}
echo $sample
echo $line
echo $id
echo "works"
done
Here is the problem: Sample is echoed perfectly, just as are $line and "works". But $id is not working, and I have no idea what I am missing here