This subchapter looks at tail, a Unix (and Linux) command.
tail is used to report the last lines of a text file.
The default operation of tail is the last 10 lines of a text file to standard output (the example is from a file with less than 10 lines).
$ tail xml2Conf.sh
# Configuration file for using the XML library in GNOME applications
XML2_LIBS="-lxml2 -lz -lpthread -licucore -lm "
example: most recent user
Here is how to use the tail utility to show the last user created on the current system:
$ tail -1 /etc/passwd
number of lines
You can use the -n option to set the number of lines, blocks, or bytes to output.
The option tail -n1 filename shows the last line.
$ tail -n1 xml2Conf.sh
The --lines=N option is equivalent to the -nN option.
An obsolete format (still used on Sun Solaris, where the -n option is not supported) uses just the number of lines as the option.
$ tail -1 xml2Conf.sh
number of characters
The option tail -c8 filename shows the last eight (8) characters (bytes).
$ tail -c8 xml2Conf.sh
Notice in the example that you only see seven characters. The newline character is the eighth character.
The --bytes=N option is equivalent to the -cN option.
An obsolete format (still used on Sun Solaris, where the -c option is not supported) uses the number of character followed by a c as the option.
$ tail -8c xml2Conf.sh
suppressing file names
If you provide tail with more than one file name, then it report the file names before the last lines of each file.
$ tail -n2 *Conf.sh
==>. xml2Conf.sh <.==
==>. xml1Conf.sh <.==
You can suppress the file name(s) with the --silent option. This is particularly useful if you are going to pipe the results to other Unix tools.
$ tail -n2 --silent *Conf.sh
The --quiet and -q options are equivalent to the --silent option.
file (log) monitoring
Use the -f (follow) option to monitor a log file. With the -f option, the tail utility will continue to monitor the file and send any new lines to standard out (unless redirected or piped elsewhere).
$ tail -f importantlogfile.txt
In most versions of Unix, the --follow or --follow=descriptor options are equivalent to the -f option.
If the file being monitored might be rotated, use the -F (follow) option to monitora file, even if the orginal version of the file is renamed or removed and a new version of the file (with the same name) is created.
$ tail -F importantlogfile.txt
Use Control-C to interrupt the file monitoring.
You can append the ampersand (& to make the file monitoring a background process.
GNU Emacs emulates this Unix utility with the auto-revert-tail-mode mode.
In most versions of Unix, the --follow=name --retry option is equivalent to the -F option.
On November 8, 2010, Ramesh Natarajan named this the number 42 most frequently used Unix/Linux command at this web page 50 Most Frequently Used UNIX / Linux Commands (With Examples).
In June 2009, Ken Milberg named this command as one of the Top 50 universal UNIX commands at this web page Top 50 Universal INIX commands. Note that this web page requires agreeing to be spammed before you can read it.
comments, suggestions, corrections, criticisms
free music player coding example
Coding example: I am making heavily documented and explained open source code for a method to play music for free almost any song, no subscription fees, no download costs, no advertisements, all completely legal. This is done by building a front-end to YouTube (which checks the copyright permissions for you).
View music player in action: www.musicinpublic.com/.
Create your own copy from the original source code/ (presented for learning programming).
This section is under the category of owning cirticism.
In response to a posting about my article collecting social media, Moderator +Andrew Smith (Technology addict, Web Developer, API guru, futsal and football wannabe, and all round nice guy!, Swordfox Design, arrowtown, new zealand) of the Google+ community Web Developers, Web Designers, Web Coding claims Quite frankly this is self promotion, and your site is not of great quality. I can see how +Joost Schuur would think this of not high enough a standard.
Because I no longer have the computer and software to make PDFs, the book is available as an HTML file, which you can convert into a PDF.
Names and logos of various OSs are trademarks of their respective owners.