I want to monitor the logs continously and echo the output if keyword appears then continues the monitoring!!
My question is how to perform the below operation
Tail the logs. If keyword[down] matches then echo, else continue monitoring.
I tried this:
tail -F /data/log/test.log | egrep -io 'got signal 15 | now exiting' | while read -r line ; do case "$line" in "got signal 15") echo "hi" ;; "now exiting") echo "hi2" ;; *) esac done
but its not working properly with tail statement as the same script works properly if i use cat or less
Please suggest what i did wrong here.