Developer(s) | Various open-source and commercial developers |
---|---|
Written in | C |
Operating system | Unix, Unix-like, V, Plan 9, Inferno, MSX-DOS, FreeDOS |
Platform | Cross-platform |
Type | Command |
License | Plan 9: Lucent Public License or GPLv2 or MIT License coreutils: GPLv3+ |
tail is a program available on Unix, Unix-like systems, FreeDOS and MSX-DOS used to display the tail end of a text file or piped data.
The version of tail
bundled in GNU coreutils was written by Paul Rubin, David MacKenzie, Ian Lance Taylor, and Jim Meyering. [1] The command is available as a separate package for Microsoft Windows as part of the UnxUtils collection of native Win32 ports of common GNU Unix-like utilities. [2] The FreeDOS version was developed by M. Aitchison. [3] A tail
command is also part of ASCII's MSX-DOS2 Tools for MSX-DOS version 2. [4]
CCZE is tail-like while displaying its output in color. [5]
pctail is similar to CCZE. It is a colorized tail programmed in Python which tails and colorizes syslog output. [6]
Inotail was an implementation using the inotify Linux kernel interface (introduced in version 2.6.13 in August 2005) to check whether new data is available instead of polling every second, as the original tail did. [7] However, newer versions[ which? ] of tail also started using inotifiy when possible, so Inotail became deprecated and is not longer maintained.
MultiTail not only displays logfiles in colors, it can also merge, filter, scrollback and split a terminal window into subwindows. [8] It is more or less a combination of tail, sed, watch, CCZE/pctail, grep, diff, Beeper and others.
The command-syntax is:
tail [options] <filename>
By default, tail will output the last 10 lines of its input to the standard output. With command line options, the amount of output and the units (lines, blocks or bytes) may be changed.
In the following example only the last line of the reports is output:
$ tail-n1report-13* ==> report-1301 <==Total tons output for month of January '13 was 523==> report-1302 <==Total tons output for month of February '13 was 272==> report-1303 <==Total tons output for month of March '13 was 623
This example outputs the last 4 characters of the reports, silently suppressing the filenames. Notice that the count includes the newline character at the end of each line and so the output does not include a leading space one might expect.
$ tail--silent-c4report* 523272623
This example shows all lines of report from the second line onwards:
tail -n +2 report
Using an older syntax (still used in older version of 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.
As with all Unix commands, use man pages on the running system for specific options and actions.
tail has two special command line option -f
and -F
(follow) that allows a file to be monitored. Instead of just 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. Ancient versions of tail poll the file every second by default but tail from the GNU coreutils as of version 7.5 support the inotify infrastructure introduced in Linux kernel version 2.6.13 in August 2005 which only check the file when is notified of changes by the kernel.
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 keep following the log even when it is recreated, renamed, or removed as part of log rotation, at least BSD and GNU implementations provide a -F
option which is useful in cases when the user is following a log file that rotates.
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.
If the user has a command's result to monitor, the watch command can be used.
There is a GNU Emacs mode that emulates the functionality of tail -f
, called auto-revert-tail-mode.
uniq
is a utility command on Unix, Plan 9, Inferno, and Unix-like operating systems which, when fed a text file or standard input, outputs the text with adjacent identical lines collapsed to one, unique line of text.
In computing, ls
is a command to list computer files and directories in Unix and Unix-like operating systems. It is specified by POSIX and the Single UNIX Specification.
uname is a computer program in Unix and Unix-like computer operating systems that prints the name, version and other details about the current machine and the operating system running on it.
head is a program on Unix and Unix-like operating systems used to display the beginning of a text file or piped data.
The ln
command is a standard Unix command utility used to create a hard link or a symbolic link (symlink) to an existing file or directory. The use of a hard link allows multiple filenames to be associated with the same file since a hard link points to the inode of a given file, the data of which is stored on disk. On the other hand, symbolic links are special files that refer to other files by name.
The computer tool patch is a Unix program that updates text files according to instructions contained in a separate file, called a patch file. The patch file is a text file that consists of a list of differences and is produced by running the related diff program with the original and updated file as arguments. Updating files with patch is often referred to as applying the patch or simply patching the files.
dd is a command-line utility for Unix, Plan 9, Inferno, and Unix-like operating systems and beyond, the primary purpose of which is to convert and copy files. On Unix, device drivers for hardware and special device files appear in the file system just like normal files; dd can also read and/or write from/to these files, provided that function is implemented in their respective driver. As a result, dd can be used for tasks such as backing up the boot sector of a hard drive, and obtaining a fixed amount of random data. The dd program can also perform conversions on the data as it is copied, including byte order swapping and conversion to and from the ASCII and EBCDIC text encodings.
tr is a command in Unix, Plan 9, Inferno, and Unix-like operating systems. It is an abbreviation of translate or transliterate, indicating its operation of replacing or removing specific characters in its input data set.
wc
is a command in Unix, Plan 9, Inferno, and Unix-like operating systems. The program reads either standard input or a list of computer files and generates one or more of the following statistics: newline count, word count, and byte count. If a list of files is provided, both individual file and total statistics follow.
split
is a utility on Unix, Plan 9, and Unix-like operating systems most commonly used to split a computer file into two or more smaller files.
paste is a Unix command line utility which is used to join files horizontally by outputting lines consisting of the sequentially corresponding lines of each file specified, separated by tabs, to the standard output.
nl is a Unix utility for numbering lines, either from a file or from standard input, reproducing output on standard output.
rm
is a basic command on Unix and Unix-like operating systems used to remove objects such as computer files, directories and symbolic links from file systems and also special files such as device nodes, pipes and sockets, similar to the del
command in MS-DOS, OS/2, and Microsoft Windows. The command is also available in the EFI shell.
In computing, more
is a command to view the contents of a text file one screen at a time. It is available on Unix and Unix-like systems, DOS, Digital Research FlexOS, IBM/Toshiba 4690 OS, IBM OS/2, Microsoft Windows and ReactOS. Programs of this sort are called pagers. more
is a very basic pager, originally allowing only forward navigation through a file, though newer implementations do allow for limited backward movement.
In computing, tee
is a command in command-line interpreters (shells) using standard streams which reads standard input and writes it to both standard output and one or more files, effectively duplicating its input. It is primarily used in conjunction with pipes and filters. The command is named after the T-splitter used in plumbing.
In computing, sleep is a command in Unix, Unix-like and other operating systems that suspends program execution for a specified time.
In computing, sort is a standard command line program of Unix and Unix-like operating systems, that prints the lines of its input or concatenation of all files listed in its argument list in sorted order. Sorting is done based on one or more sort keys extracted from each line of input. By default, the entire input is taken as sort key. Blank space is the default field separator. The command supports a number of command-line options that can vary by implementation. For instance the "-r
" flag will reverse the sort order.
sum is a legacy utility available on some Unix and Unix-like operating systems. This utility outputs a 16-bit checksum of each argument file, as well as the number of blocks they take on disk. Two different checksum algorithms are in use. POSIX abandoned sum
in favor of cksum.
The csplit
command in Unix and Unix-like operating systems is a utility that is used to split a file into two or more smaller files determined by context lines.
cat
is a standard Unix utility that reads files sequentially, writing them to standard output. The name is derived from its function to (con)catenate files . It has been ported to a number of operating systems.