How to pipe tail -f into awk
问题 I'm trying to set up a script where an alert is generated when a certain string appears in a log file. The solution already in place greps the whole log file once a minute and counts how often the string appears, using the log line's timestamp to count only occurrences in the previous minute. I figured it would be much more efficient to do this with a tail, so I tried the following, as a test: FILENAME="/var/log/file.log" tail -f $FILENAME | awk -F , -v var="$HOSTNAME" ' BEGIN { failed_count