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!
Got Feedback? Join the discussion at discuss.howtogeek.com
Comments (1)
Programmer by day, geek by night, The Geek, also known as Lowell Heddings, spends all his free time bringing you fresh geekery on a daily basis. You can follow him on Google+ if you'd like.
- Published 07/19/10




Shouldn’t that read something more like:
tail -f /path/to/apache/error.log | grep -v “PHP Notice”