Is is possible to filter the output of tail

tailunix

I'd like to tail a file but only output lines that have a certain string in them. Is this possible?

Best Answer

use grep. Its built just for that purpose.

To find lines from a tail of /var/log/syslog that have "cron" in them, just run:

tail -f /var/log/syslog | grep cron

And since it accepts anything over stdin, you can use it on the output of any other command as well, by piping in the same way as above (using the | symbol).

Related Topic