Watch Multiple Files Simultaneously

Problem

Performing debugging and you need to view the output, of more than one file at once.



Solution

A simple way to keep an eye on a file is with tail.


tail -f logfile

You can background this, by appending an ampersand:


tail -f logfile&



Example


But if you want to watch multiple files, how do you know which one received the update.

Sed to the rescue:


tail -f logfilea | sed 's/^/logfilea: /'&
tail -f logfileb | sed 's/^/logfileb: /'&



Reference

[tags], Unix Coding School[/tags]



Leave a Reply

Your email address will not be published. Required fields are marked *