I'm doing this shell script code that should pass each line of a text file, and determine if the sentence is positive or negative depending on the IF condition
#!/usr/bin/ksh
file="${1}"
while read line;do
pos=$(grep -oP ':\)|;\)|:D' $file | wc -l)
neg=$(grep -oP ':\(' $file | wc -l)
if (( $pos * 2 > $neg * 5 )) ;then
echo "Sentença Positiva "
else
echo "Sentença Negativa"
fi
sleep 1
done <"$file"
But how much do I execute the script on top of this text file: test.txt
teste:) teste :) teste :) teste :)
teste:( teste :( teste :( teste :(
Instead of returning it:
Sentença Positiva
Sentença Negativa
it returns the two negatives:
Sentença Negativa
Sentença Negativa
How do I fix this problem?