Linux – Combine tail -f with grep

greplinuxtail

Hi I wanna keep looking at a log file, but I also don't wanna see irrelevant stuff, I'm only interested in anything with "foobar" in it.

So if I was tailing the file I would do

 tail file | grep "foobar"

Now that I'm adding the -f option, is there a way to somehow only show the stuff that I want? using grep or other technique?

Best Answer

You almost wrote the answer, which is :

tail -f file.log | grep "foobar"

That's it.