I wrote a small bash script. It will try to find the word ERROR. If found the resulting value will be non-zero numeric (for example 25. I mentioned in the script but it is variable numeric value), and if not found, it will be 0.
My problem is: I want to use case
statement, such that if output is not zero, then execute the following command
truncate -s 0 /root/test/wayfile.log && screen -X -S wowow quit &
Script here:
#! /bin/bash
case "$(grep ERROR /root/test/wayfile.log | wc -w)" in
25) echo "empty log file and kill screen: $(date)" >> /var/log/finderror.txt
truncate -s 0 /root/test/wayfile.log && screen -X -S wowow quit &
;;
0) # all ok
;;
esac