I have to search word occurrences in a plain text file using a script. The script that I wrote is:
#!/bin/bash
if [ $# -ne 1 ]
then
echo "inserire il file che si vuole analizzare: "
read
fileIn=$REPLY
else
fileIn=$1
fi
echo "analisi di $fileIn"
for parola in $( cat $fileIn )
do
freq=${vet[$parola]}
vet[$parola]=$(( freq+1 ))
done
for parola in ${!vet[*]}
do
echo $parola ${vet[$parola]}
done
unset array
But when I run it I get this error:
./script02.sh: line 16: qua.: syntax error: invalid arithmetic operator (error token is ".")
What's wrong and how do I fix it? Thanks.