music
OSdata.com: programming text book 

OSdata.com

tail

summary

    This subchapter looks at tail, a Unix (and Linux) command.

syntax:

tail [options…] [file…]
shells:ashbashbshcshkshshtcshzsh
File Name:tailDirectory:/usr/bin/Type:External

free book on Unix/Linux System Administration

Teach Yourself Unix/Linux System Administration and Shell Programming

free computer programming text book project

table of contents
If you like the idea of this project,
then please donate some money.
more information on donating

Google

tail

    This subchapter looks at tail, a Unix (and Linux) command.

    tail is used to report the last lines of a text file.

default

    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_LIBDIR="-L/usr/lib"
    XML2_LIBS="-lxml2 -lz -lpthread -licucore -lm "
    XML2_INCLUDEDIR="-I/usr/include/libxml2"
    MODULE_VERSION="xml2-2.7.3"

    $

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
    MODULE_VERSION="xml2-2.7.3"
    $

    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
    MODULE_VERSION="xml2-2.7.3"
    $

number of characters

    The option tail -c8 filename shows the last eight (8) characters (bytes).

    $ tail -c8 xml2Conf.sh
    -2.7.3"
    $

    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
    -2.7.3"
    $

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 <.==
    XML2_INCLUDEDIR="-I/usr/include/libxml2"
    MODULE_VERSION="xml2-2.7.3"

    ==>. xml1Conf.sh <.==
    XML2_INCLUDEDIR="-I/usr/include/libxml1"
    MODULE_VERSION="xml2-2.7.1"
    $

    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
    XML2_INCLUDEDIR="-I/usr/include/libxml2"
    MODULE_VERSION="xml2-2.7.3"

    XML2_INCLUDEDIR="-I/usr/include/libxml1"
    MODULE_VERSION="xml2-2.7.1"
    $

    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.

other

    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

please contact us

your name:
email address:
phone number:
message:

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.”


return to table of contents
free downloadable college text book
free downloadable system administrator and shell programming book

view text book
HTML file

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.

previous page next page
previous page next page

free book on Unix/Linux System Administration

Teach Yourself Unix/Linux System Administration and Shell Programming

free computer programming text book project

Building a free downloadable text book on computer programming for university, college, community college, and high school classes in computer programming.

If you like the idea of this project,
then please donate some money.

send donations to:
Milo
PO Box 1361
Tustin, California 92781

Supporting the entire project:

    If you have a business or organization that can support the entire cost of this project, please contact Pr Ntr Kmt (my church)

more information on donating

Some or all of the material on this web page appears in the
free downloadable college text book on computer programming.


Google


Made with Macintosh

    This web site handcrafted on Macintosh computers using Tom Bender’s Tex-Edit Plus and served using FreeBSD .

Viewable With Any Browser


    †UNIX used as a generic term unless specifically used as a trademark (such as in the phrase “UNIX certified”). UNIX is a registered trademark in the United States and other countries, licensed exclusively through X/Open Company Ltd.

    Names and logos of various OSs are trademarks of their respective owners.

    Copyright © 2012, 2013, 2014 Milo

    Created: August 12, 2014

    Last Updated: August 6, 2013


return to table of contents
free downloadable college text book
free downloadable system administrator and shell programming book

previous page next page
previous page next page