well im in this for hours and I can't understand why I cant save the values to the variable:
let inicio=${tlinhas[0]}/2+1
tail -n +$inicio $1 | head -n $tlinhas | grep $2 | while read linha
do
let palavras=$palavras+$(echo $linha | wc -w)
echo $palavras
done
printf "%d" $palavras
the problem is that every time I print the variable palavras its always zero but if I print it inside the while it has the value 14
[leganuno@LegaNuno-PC FichasIndividuais]$ ./exercicio1.sh f1 Licenciatura
7
7
0