Monday, February 25, 2008

The Useful "tail -f"

"tail" is a program in UNIX-like system to print a little part of the end of a file (it's counterpart is easy to guess : "head" to print the beginning instead). At first, I didn't find this program anything special, just some program that I think I might use someday when I need it.

I find a more useful use of it when quite a long time ago I try to setup my tv-tuner to work on linux , which is quite painful to do at that time. Thanks to one reference that on the net (which I lost the link, unfortunately) that use "tail -f" to view the change in log file in realtime (it was used to watch the loading/unloading of the driver to see the effect of different parameters, pure "fun" ;) ), I got myself one very handy tool to watch log file (or any file with the same nature) since then.

When you have trouble with servers or system in general, you could troubleshoot better with this. However, "tail -f" could be really handy for programming too. When you want to trace program as a work around when you have some problem to show them in screen, just print them to file and watch it's changes/appending in realtime and you can avoid having to scan the whole log file after-the-fact.

It's available on most of the system e.g: Cygwin for windows. So, you can rely on it most of the time.

No comments: