I have a server and a local PC. When the local PC boots up, I run the following script to display the output from the server logs locally on the PC.

/usr/bin/ssh -p '444' 'user@remoteserver' "tail -f /log/short.log"

So far everything works great, but what I would like to do is to also pass this output to another background script each time a new line arrives in the "tail". The background script would then check if the given line contains any keywords, and if it's a match, then it would play a sound, while the original tail would still work and list the data on the screen as previously.

The script for checking keywords/playing audio I can do easily, but the part that I don't understand is how can I pass each new line to my script and still have the output printed on the screen.

1 Answer 1


You can use tee to split a single input stream into two or more output streams. tee writes all input to standard output and to the file(s) named on its command line.


ssh somewhere "tail -f /var/log/whatever.log" | tee /dev/tty | /usr/local/bin/myscript

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .