Reputation: 13150
I am not sure this can be done, but with linux, you never know it's limits.
I am tailing an apache log:
\#tail -f apachelog.access-log
It gets me what I want, but I want to narrow down what it returns. Here's a typical row I'll get:
2011-01-28T04:20:59-07:00 SERVER03 apache: 10.0.0.1 - - [28/Jan/2011:04:20:59 +0000] "POST /a/ HTTP/1.1" 200 4461 "http://somesite.net/" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13"
Is it possible to filter what I am tailing? At times, I'd like to only view the referring site. And other times I'd like to view 2 or 3 other items.
Upvotes: 3
Views: 7012
Reputation: 283971
If you want to view just one column of the log live, you should consider piping the tail -f
output through awk
, sed
, or perl
. All of which would be better suited to a question on unix.stackexchange.com than SO.
Upvotes: 0
Reputation: 112424
Use tail to start.
$ tail -f logfile | grep 'PATTERN' | less -f
WHat I usually do though is use less
, then hit ^C to get the colon prompt. Search or whatever. Then type 'F' and less goes back to 'follow' mode.
Upvotes: 1
Reputation: 882806
You can quite easily execute:
tail -f apachelog.access-log | grep SERVER03
which will only give you lines containing the string SERVER03
.
Upvotes: 2