Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I wanted to combine two continuous text streams generated by tail -f into one and watch them in the same screen. Is it possible? Both text streams are line-oriented (e.g. logs), if that helps.

Update: just to make it clear, the two tail -f streams are not on local files but from two remote SSH sessions, e.g. ssh remote-host tail -f file.log

share|improve this question

tail supports several files, for example:

tail -q -f file1 file2
share|improve this answer
Thanks very much for the answer! I wasn't very clear in the original question. I just updated the description to make it more specific about streams over SSH. – Riobard Jun 19 '13 at 16:20

If you just want to watch the log lines, and don't need the data afterwards, why not:

ssh host1 tail -f file & ssh host2 tail -f file &

To accomplish what you say in the comment, if you have the pee command (moreutils):

pee 'ssh host1 tail -f file' 'ssh host2 tail -f file' < /dev/null
share|improve this answer
Thanks! I was hoping there is a tool to combine two remote streams into one locally, so viewing them is easier (without creating tmp files), but more importantly I can then pipe them together to another downstream process. – Riobard Jun 22 '13 at 23:27

The quick and dirty way that comes to mind is to tail each log file on each remote machine and redirect them to temporary files locally. Then, tail both logs with the method golimar suggested.

  1. ssh user@host1 -C tail -f /path/to/log >> /tmp/log1.tmp
  2. ssh user@host2 -C tail -f /path/to/log >> /tmp/log2.tmp
  3. tail -q -f /tmp/log1.tmp /tmp/log2.tmp

It's not pretty, requires keeping local data, and requires the first 2 commands to be background'ed (or run in screen or similar), but it should get the job done!

share|improve this answer
Thanks! This works. I was hoping there might be some rare commands/options that I could do it in one line without creating tmp files. – Riobard Jun 19 '13 at 23:31
if the files are in the same server you could do ssh user@host -C tail -q -f /path/to/log1 /path/to/log2 – Miguel Jul 17 '14 at 20:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.