bash one-liners with multiple pipes
G. Matthew Rice
matt-s/rLXaiAEBtBDgjK7y7TUQ at public.gmane.org
Tue May 11 16:55:33 UTC 2004
Henry Spencer <henry-lqW1N6Cllo0sV2N9l4h3zg at public.gmane.org> writes:
> What you *can* do, possibly at some cost in convenience, is try to roll
> all the output processing into a single program. In particular, note that
> awk can do anything that grep and sed can do, so it might be possible (if
> a little cumbersome) to just do "tail | awk".
It doesn't solve the buffering problem but:
tail -f /some/log | awk '$7 !~ /\.(gif|png|css|jpg)/ {
sub("&requestUrl=.*", "", $7);
print $1, $7
}'
Should do it and it fixes a potential bug in his earlier example.
The bug being that the first field [$1] is probably IP addresses but could
also be domain names [such as i.am.a.gif.com ;)].
Even with fflush in awk, I still get the buffering.
However, there's a bigger potential problem. Is his version of tail going to
notice when his log file gets truncated and/or moved out of the way?
Something to test for, at least.
Regards,
--
g. matthew rice <matt-s/rLXaiAEBtBDgjK7y7TUQ at public.gmane.org> starnix inc.
phone: 905-771-0017 x242 thornhill, ontario, canada
http://www.starnix.com professional linux services & products
--
The Toronto Linux Users Group. Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml
More information about the Legacy
mailing list