Posted By

edeustace on 02/03/10


Tagged

filter grep tail


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

edeustace
edeustace2


Filter the output of a tail


 / Published in: Bash
 

When tailing a log file, its sometimes handy to only show parts of it that you are interested in, this simple pipe does the job.

  1. tail -f /myFile.log | grep 'string_to_find'
  2.  
  3. # for a log file
  4. # 1: hello
  5. # 2: string_to_find on line 2
  6. # 3: hello again
  7.  
  8. # the command above will output:
  9. # string_to_find on line 2
  10.  
  11. # to do an invert match just use -v with grep
  12. # tail -f /myFile.log | grep -v 'string_to_ignore'

Report this snippet  

You need to login to post a comment.