1

I'd like to tail -f the output of access_log on RHEL 6.8 but pipe and grep that output to act as a filter. Is there such an option?

That is I'd like live output from:

# tail -f error_log | grep <<ON.THIS.IP.ADDY>>

Currently I'm doing something akin to this, but it's clunky:

watch -n 5 'tail -n 10 access_log | grep <<ON.THIS.IP.ADDY>>'
2
  • Clunky? What's wrong with the first command? Jul 14 '16 at 17:43
  • The terminal would appear to 'hang' after the first command. The accepted answer below was all I needed. Adding --line-buffered solved all problems.
    – Rick
    Jul 14 '16 at 18:59
3

I just did a tail -f <nginx-access.log> | grep <ip> and as expected new lines showed up regularly.

What happens when you try? Could it be hat your grep buffers (I think i've seen that), in that case it might help to add --line-buffered to the grep.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.