3
I am making this shell script code that must go through each line of a text file, and determine whether the sentence is positive or negative according to 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 when I run the script on top of this text file: test.txt
teste:) teste :) teste :) teste :)
teste:( teste :( teste :( teste :(
Instead of him returning:
Sentença Positiva
Sentença Negativa
he returns the two negatives:
Sentença Negativa
Sentença Negativa
How do I fix this problem?