I have this line that appears every minute in my log file:

2016-03-29 21:52:46,226 INFO     200 GET /api/ping ( 0.34ms

I want to tail this log file without showing these lines.

I tried:

tail -f log.txt | grep -v "ping"
  • Do you mean that what you tried don't work? Mar 30, 2016 at 15:17
  • 1
    The solution has been written a couple of times in the context of other shell commands. You should look for "stdbuf" in the upper right corner of this web page. Mar 30, 2016 at 15:18
  • What is the problem? Just tried this on my machine and it works as expected. echo "..GET /api/ping (0.." | grep -v "ping" yelids a 1 result with no matches.
    – Matt Clark
    Mar 30, 2016 at 15:29
  • @MattClark echo sthing is easy because its output is finished and flushed. A continuous pipe means buffering which is usually a friend but when waiting for the buffer to fill and flush means an impact on the process, it's an ugly enemy. Luckily, it can be tamed with stdbuf among a couple of options. Mar 30, 2016 at 19:25
  • even still, tail -n 0 -f test | grep -v "ping" and run this in another terminal echo "..GET /api/ping (0.." >> test still result in no output. I've tested this on 4 different unix distros, and cygwin on windows. All have the same expected behavior.
    – Matt Clark
    Mar 30, 2016 at 20:40

1 Answer 1


You could do something like this:

tail -F ~/Your.log | while read LINE;do

if [[ ! "$LINE" =~ "ping" ]]; then

   echo $LINE 


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.