Tail (Unix)

Tail (Unix)

tail is a program on Unix and Unix-like systems used to display the last few lines of a text file or piped data.

yntax

The command-syntax is:

tail [options]

By default, tail will print the last 10 lines of its input to the standard output. With command line options the number of lines printed and the printing units (lines, blocks or bytes) may be changed. The following example shows the last 20 lines of "filename":

tail -n 20 "filename"

This example shows the last 15 bytes of all files starting with "foo":

tail -c 15 "foo*"

This example shows all lines of "filename" from the second line onwards:

tail -n +2 "filename"

Using an older syntax (still used in Sun Solaris as the -n option is not supported), the last 20 lines and the last 50 bytes of "filename" can be shown with the following command:

tail -20 "filename" tail -50c "filename"

However this syntax is now obsolete and does not conform with the POSIX 1003.1-2001 standard. Even if still supported in current versions, when used with other options (like -f, see below), these switches could not work at all.

File monitoring

tail has a special command line option -f (follow) that allows a file to be monitored. Instead of displaying the last few lines and exiting, tail displays the lines and then monitors the file. As new lines are added to the file by another process, tail updates the display. This is particularly useful for monitoring log files. The following command will display the last 10 lines of "messages" and append new lines to the display as new lines are added to "messages":

tail -f /var/adm/messages

To interrupt tail while it is monitoring, break-in with CTRL-C. This command can be run "in the background" with &, see job control.

Variants

* [http://freshmeat.net/redir/ccze/33590/url_homepage/ccze.html CCZE] is tail-like while displaying its output in color
* [http://sourceforge.net/projects/pctail/ pctail] Like CCZE: Python Colorized TAIL, a colorized tail made in python which tails and colorizes syslog output.
* [http://www.goof.com/pcg/marc/root-tail.html root-tail] displays the output in the X-server root window
* [http://distanz.ch/inotail/ Inotail] : the regular tail polls every second to see if new data can be displayed. Inotail uses the Linux kernel's inotify-interface so that it only checks for new data when there really is some.
* [http://www.vanheusden.com/multitail/ MultiTail] not only displays logfiles in colors, it can also merge, filter, scrollback and split a terminal window in subwindows. It is more or less a combination of tail, sed, watch, CCZE/pctail, grep, diff, [http://cosoleto.free.fr/beeper/ Beeper] and others.

ee also

*head
*List of Unix programs

External links

* [http://www.gnu.org/software/coreutils/manual/html_node/tail-invocation.html GNU Project documentation for tail]
* [http://www.freebsd.org/cgi/man.cgi?query=tail&apropos=0&sektion=0&manpath=FreeBSD+5.3-RELEASE+and+Ports&format=html FreeBSD documentation for tail]
* [http://www.thelinuxblog.com/linux-man-pages/1/tail tail man page]


Wikimedia Foundation. 2010.

Игры ⚽ Нужно сделать НИР?

Look at other dictionaries:

  • Tail (Unix) — tail est une commande UNIX qui permet d afficher les dernières lignes de texte d un fichier ou de l entrée standard. Syntaxe La syntaxe est la suivante : tail [options] <fichier> Par défaut, tail affiche les 10 dernières lignes de son… …   Wikipédia en Français

  • Tail (Unix) — tail (englisch „Rest“, „Ende“) ist ein Programm für Unix und unixähnliche Betriebssysteme zur Ausgabe der letzten Zeilen einer Datei. Im Gegensatz zu einem Texteditor ist der Benutzer jedoch mit tail nicht in der Lage Änderungen an der Datei… …   Deutsch Wikipedia

  • tail (Unix) — tail (englisch „Rest“, „Ende“) ist ein Programm für Unix und unixähnliche Betriebssysteme zur Ausgabe der letzten Zeilen einer Datei. Im Gegensatz zu einem Texteditor ist der Benutzer jedoch mit tail nicht in der Lage Änderungen an der Datei… …   Deutsch Wikipedia

  • tail (Unix) — tail est une commande UNIX qui permet d afficher les dernières lignes de texte d un fichier ou de l entrée standard. Syntaxe La syntaxe est la suivante : tail [options] <fichier> Par défaut, tail affiche les 10 dernières lignes de son… …   Wikipédia en Français

  • UNIX-Kommandos — Unix Systeme zeichnen sich durch eine Vielzahl von Kommandos aus, mit denen sich über eine Shell das Betriebssystem bedienen lässt. Die Syntax dieser Kommandos weicht unter den verschiedenen Systemen voneinander ab. Es existieren die beiden… …   Deutsch Wikipedia

  • Unix-Befehle — Unix Systeme zeichnen sich durch eine Vielzahl von Kommandos aus, mit denen sich über eine Shell das Betriebssystem bedienen lässt. Die Syntax dieser Kommandos weicht unter den verschiedenen Systemen voneinander ab. Es existieren die beiden… …   Deutsch Wikipedia

  • Unix-Kommando — Unix Systeme zeichnen sich durch eine Vielzahl von Kommandos aus, mit denen sich über eine Shell das Betriebssystem bedienen lässt. Die Syntax dieser Kommandos weicht unter den verschiedenen Systemen voneinander ab. Es existieren die beiden… …   Deutsch Wikipedia

  • Unix Kommandos — Unix Systeme zeichnen sich durch eine Vielzahl von Kommandos aus, mit denen sich über eine Shell das Betriebssystem bedienen lässt. Die Syntax dieser Kommandos weicht unter den verschiedenen Systemen voneinander ab. Es existieren die beiden… …   Deutsch Wikipedia

  • Tail (disambiguation) — Tail describes the rear portion of an animal s body, especially as a flexible appendage.Tail may also refer to: * Tail (Unix), a Unix program used to display the last few lines of a file * Tails (Lisa Loeb album), a 1994 album by Lisa Loeb * Tail …   Wikipedia

  • tail — tail  утилита в UNIX, выводящая несколько (по умолчанию 10) последних строк из файла. Синтаксис tail [параметры] имя файла Ключ n <количество строк> (или просто <количество строк>) позволяет изменить количество выводимых строк:… …   Википедия

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”