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[1013]: New relevant interface vboxnet0.IPv4 for mDNS.
Feb 26 02:25:24 laptop1413 avahi-daemon[1013]: 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.

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <img> <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote> <h1> <h2> <h3> <h4> <h5> <h6> <p> <br>
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Image links with 'rel="lightbox"' in the <a> tag will appear in a Lightbox when clicked on.

More information about formatting options

Type the characters you see in this picture. (verify using audio)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.