The problem is with this code:
words=`wc -l /home/tmp/logged.log | awk '{print $1}'`;
if [ $words == 26 ]
then
echo $words
echo Good
else
echo Not so good
fi
it always returns the else statement. Even tho the result is 26. I also tried
words=`wc -l < /home/jonathan/tmp/logged.log`;
try to use [ $words -eq 26 ]
instead of [ $words == 26 ]
or [ 26 == 26 ]
to check that statement works properly
Because ==
is not valid. Use =
if [ $words = 26 ]
By the way you can use cut
instead of awk
.
wc -l /home/tmp/logged.log | cut -f1 -d" "
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With