Watch Multiple Files Simultaneously


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



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&



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: /'&



[tags], Unix Coding School[/tags]


If you have found my website useful, please consider buying me a coffee below 😉

Leave a Reply

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