I'm trying to find errors in log, and I need to send message if any number of error is greater than 0.
My script looks like this:
var1=$(grep Errors: rclone.log | awk '{print $2;}')
for i in "${var1}"
do
if [ "$i" -gt "0" ]; then
echo "Errors"
else
echo "No errors"
fi
done
Variable $i looks like this
0 2 1 0 0 0 10  
But if I run my script, I'm always see errors like this:
./test.sh: line 7: [: 0
2
1
0
0
0
10: integer expression expected
So my idea, is to find all number in $i greater than 0. Where is my mistake?
My input file:
Checking:
Errors:                 0
Checks:            741286 / 751291, 99%
Transferred:         2005 / 2005, 100%
Elapsed time:    39m26.2s
Checking:
Errors:                 0
Checks:            741465 / 751470, 99%
Transferred:         2005 / 2005, 100%
Elapsed time:    39m26.7s
Checking:
Errors:                 10
Checks:            741616 / 751621, 99%
Transferred:         2005 / 2005, 100%
Elapsed time:    39m27.2s
 
    