I need to do the following but I don't know exactly what to do.
I need to monitor a file ... with tail -f for example, but I know that I could do it with awk, wait for a specific string ... , then perform an action, call a script, etc.
Let's say that my file name is test.txt , I need to wait for a string like "system call" ... if that happens, I will take that file to another place, or email, etc.
How can I do it from the CLI, without using additiona scripts, etc?
On the top of my head, no debugging done, using bash since I've no idea how to call different programs from awk:
tail -f test.txt | while read D ; do if [ "$D" = "mail this file to me" ] ; then mail -s "keyword mentioned in log" some.email@host.com < test.txt ; fi ; done
tail -f test.txt | while read D ; do echo "$D" |grep "PUT YOUR STRING HERE" ; if [ $? == "0" ]; then mailx -s "keyword mentioned in log" some.email@host.com < test.txt ; fi ; done