After we published "Linux Tail Command - Everything You Need to Know" we received quite a few questions. Most of them were asking how to tail multiple files at once. In this Linux quick tip we will show you a few ways to tail -f (follow) multiple files.
Tail Multiple Files with Native Tail Command
The easiest way to accomplish this, without installing any additional software, is to use the tail command with multiple files as arguments.
tail -f file1 file2
$ tail -f access.log httpd.log ==> access.log <== 18.104.22.168 - - [15/May/2015:18:32:56 +0100] "GET… 22.214.171.124 - - [15/May/2015:22:25:11 +0100] "GET… 126.96.36.199 - - [15/May/2015:22:25:11 +0100] "POST… 188.8.131.52 - - [15/May/2015:22:31:08 +0100] "GET… 184.108.40.206 - - [15/May/2015:22:31:08 +0100] "POST… ==> httpd.log <== 220.127.116.11 - - [15/May/2015:18:31:08 +0100] "POST… 18.104.22.168 - - [15/May/2015:18:31:25 +0100] "GET… 22.214.171.124 - - [15/May/2015:18:31:25 +0100] "POST… 126.96.36.199 - - [15/May/2015:18:32:10 +0100] "GET… 188.8.131.52 - - [15/May/2015:18:32:11 +0100] "POST… 184.108.40.206 - - [15/May/2015:18:32:56 +0100] "GET…
You can also tail multiple files with different options like so:
tail -F /var/log/messages -f /var/log/messages
To learn about the available options read "Linux Tail Command - Everything You Need to Know".
Using multitail Utility to Tail Multiple Files
The multitail utility allows you to tail multiple files and output in the terminal. Mutlitail provides most of the popular options of native tail and it adds additional functionality like tee command simulation, colorization, filtering and the ability to merge output. It also provides options for customized screen layouts. Multitail is available to many Linux distributions and can easily be installed with your package manager.
Install multitail with DNF
In Fedora you can simply use DNF to install the package like so:
sudo dnf install multitail
Install multitail with Yum
For Red Hat or CentOS 7, you must install the epel repository first:
sudo yum install epel-release sudo yum install multitail
Install multitail with APT
In Ubuntu and Debian variants you can use apt-get like so:
sudo apt-get install multitail
Multitail Basic Usage
To tail multiple files with multitail simply invoke the program followed by the two filenames you wish to follow.
$ multitail access.log httpd.log
The nice thing about multitail is it creates two panes, one for each file. These panes can scroll independently and search works across both panes.
Multitail is a feature rich utility and would need it's own complete tutorial to even begin to scratch the surface. For more information and options visit the man pages listed in the resources section.
In this Linux quick tip we showed you how to tail multiple files with the tail command. We also outlined some of the benefits of using an optional tool called multitail. Both have their pros and cons, but now you know, and knowing is half the battle.
This site uses Akismet to reduce spam. Learn how your comment data is processed.
You can use xtail too
love the gi joe reference!
Join Our Newsletter
- Bash Scripting (17)
- Basic Commands (50)
- Featured (7)
- Just for Fun (5)
- Linux Quick Tips (98)
- Linux Tutorials (60)
- Miscellaneous (15)
- Network Tools (6)
- Reviews (2)
- Security (32)
Leave a Reply