Filter the output of a tail


/ Published in: Bash
Save to your folder(s)

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.


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.