Search code examples
sshtail

ssh tail output lines only with keyword


I'm trying to tail a large file in an ssh command prompt, but I need to filter it so it only displays lines that contain a particular keyword in them.

I'm using this command currently to tail.

# tail /usr/local/apache/logs/access_log

If possible please let me know what I would add to this command to accomplish this.


Solution

  • You can pipe the output of tail and use grep. To

    filter so it only displays lines that contain a particular keyword in them

    you could do:

    tail /usr/local/apache/logs/access_log | grep "keyword" 
    

    where you'd replace keyword with your keyword.