I like matli's answer. Bruno De Fraine's answer is also good in that it uses only shell command commands and not other programs (like awk). He suffers from the problem that the whole line must match the magic line. It is not clear from the question what part of the requirement is.
I would modify it a bit to deal with the "as soon as" sentence in the original question
logfile_generator | tee logfile.out | nawk '/pattern/ {system("echo do something here")}'
where logfile_generator is the program that first creates the log file. This modification does "something" as soon as the magic string is found.
source share