So I monitor some logs (/var/log/apache2/error.log
) with the command tail -f
, and only print the errors (grep ':error'
).
I combined both of these in a script (namely, watch_error_log
.)
NB: I am part of the adm group.
So far so good.
But when I attempt more useful tricks, it won't work, such as :
$ while read APACHE_DEBUG_LOG; do echo "$APACHE_DEBUG_LOG"; done < <(watch_error_log)
or
$ watch_error_log | while read DEBUG_LOG_APACHE; do echo "$DEBUG_LOG_APACHE"; done;
Of course, my goal is not to ECHO the output. But If echo won't work, I know it is not because of the other program I want to use.
Why doesn't it work, and how can I make this work ?
After reading piped command after grep not working, I tried to add --line-buffered
and everything's good.
watch_error_log
essentially containstail -f somefile | grep :error
, right? – ilkkachu Dec 18 '17 at 08:43