Use Tail command to view growing/changing files in real time
Many a times you will feel the need to view a constanly updating file. This is a common case with logs. People usually think that tail command is only used to view the last parts of a file, but it even provides you with the ability to view growing/changing files.
Please note that, by growing I mean files to whom data is being appended constantly. Using the “-f” option, tail lets us view the data that is being added to the file in real time.
Lets try it on a log file.
[shredder12]$ tail -f /var/log/syslog
Feb 26 02:25:24 laptop1413 vmnetBridge: Adding interface vboxnet0 index:6
Feb 26 02:25:24 laptop1413 avahi-daemon: New relevant interface vboxnet0.IPv4 for mDNS.
Feb 26 02:25:24 laptop1413 avahi-daemon: Registering new address record for 192.168.56.1 on vboxnet0.IPv4.
Feb 26 02:25:24 laptop1413 kernel: [33923.405756] device vboxnet0 entered promiscuous mode
Unlike cat, less or any other utilities, tail doesn't stop after dumping the data on the terminal. It waits for data to be appended to the file, displays it as soon as its added and similarly keeps waiting for more.