• ARTICLES
SEARCH

How-To Geek

Use a Reverse Grep to Filter Tail -f Output

Have you ever used a tail -f on a logfile, only to find that it’s scrolling by way too fast for you to deal with? If you know exactly what you’re looking for, you can always grep the contents, but often you aren’t sure what you need to see. In this case, it’s useful to reverse grep instead.

For instance, if you kept getting PHP Notices in your apache error log, and assuming for the purposes of this example that you don’t feel like changing the PHP error logging levels, you can run a command like this to filter those out so you only see the warnings and errors:

tail -f | grep -v “PHP Notice”

The -v argument reverses grep to only print out lines that don’t match, so you’d end up only getting the other errors. Very useful trick!

Lowell Heddings, better known online as the How-To Geek, spends all his free time bringing you fresh geekery on a daily basis. You can follow him on if you'd like.

  • Published 07/19/10

Comments (1)

  1. Pete

    Shouldn’t that read something more like:

    tail -f /path/to/apache/error.log | grep -v “PHP Notice”

Get Free Articles in Your Inbox!

Join 134,000 newsletter readers

Email:

Go check your email!