Linux tail command

I'm not sure that this can be done, but with Linux, you never know what this limits.

I close the apache log:

\#tail -f apachelog.access-log 

He gets me what I want, but I want to narrow down what he returns. Here is a typical line that I will 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" 

Can I filter out what I tail? From time to time, I would only like to browse the site links. And once again I would like to see 2 or 3 other subjects.

+4
source share
5 answers

You can easily do:

 tail -f apachelog.access-log | grep SERVER03 

which will give you the lines containing the string SERVER03 .

+2
source

Use the tail to run.

 $ tail -f logfile | grep 'PATTERN' | less -f 

What I usually do, but use less , and then press ^ C to get a colon prompt. Search or something else. Then enter β€œF” and return to follow mode less.

+1
source

I think we can do it with the cut command

+1
source

tail -f file | egrep ... pattern ...

0
source

If you want to view only one log column live, you should consider tail -f output via awk , sed or perl . All this is better suited to the question about unix.stackexchange.com than SO.

0
source

Source: https://habr.com/ru/post/1337424/


All Articles