TAIL(1POSIX)
π TAIL(1POSIX) π
okay bestie, sit down, hydrate, because we're doing tail today and it's genuinely iconic. this page is TAIL(1POSIX) straight out of the POSIX Programmer's Manual and we're gonna go through every single line of it together, no skimming, no cap. π
π¦ PROLOG π¦
real talk before anything else: this manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ β so if you're on Linux, go consult the corresponding Linux manual page for the details on Linux behavior. orβ¦ the interface may simply not be implemented on Linux at all. π vibe check failed, moving on.
β¨ NAME β¨
tail β copy the last part of a file
πΈ SYNOPSIS πΈ
tail [-f] [-c number|-n number] [file]
π DESCRIPTION π
so the whole point of the tail utility: it shall copy its input file to the standard output, starting at a designated place. that's it. that's the gig. π
The copying shall begin at the point in the file indicated by the -c number or -n number options. That option-argument number shall be counted in units of lines or bytes, depending on whether you used -n or -c. And heads up: both line and byte counts start from 1. not zero. one. periodt.
Tails relative to the end of the file may be saved in an internal buffer, which means they may be limited in length. If such a buffer exists, it shall be no smaller than {LINE_MAX}*10 bytes. so like, a real one. πͺ
π OPTIONS π
The tail utility shall conform to the Base Definitions volume of POSIX.1β2017, Section 12.2, Utility Syntax Guidelines β except that '+' may be recognized as an option delimiter as well as '-'. quirky, but we love her.
The following options shall be supported:
-cnumber β the application shall ensure that the number option-argument is a decimal integer, optionally including a sign. That sign shall affect the location in the file, measured in bytes, where copying begins:- sign
+β copying starts relative to the beginning of the file. - sign
-β copying starts relative to the end of the file. - no sign β copying starts relative to the end of the file.
- sign
The application shall ensure that if the sign of the number option-argument is '+', the number option-argument is a non-zero decimal integer. so -c +0 is a no. π«
The origin for counting shall be 1; that is, -c +1 represents the first byte of the file, and -c -1 the last.
-fβ if the input file is a regular file, or if the file operand specifies a FIFO, then do not terminate after the last line of the input file has been copied β instead, read and copy further bytes from the input file as they become available. If no file operand is specified and standard input is a pipe or FIFO, the-foption shall be ignored. If the input file is not a FIFO, pipe, or regular file, it is unspecified whether or not the-foption shall be ignored. (so don't come for me, the standard literally said unspecified. π)-nnumber β this shall be equivalent to-c number, except the starting location in the file shall be measured in lines instead of bytes. The origin for counting shall be1; that is,-n +1represents the first line of the file, and-n -1the last.
If neither -c nor -n is specified, -n 10 shall be assumed. (that's why plain old tail gives you ten lines, bestie. you're welcome. β¨)
π OPERANDS π
The following operand shall be supported:
- file β a pathname of an input file. If no file operand is specified, the standard input shall be used.
π STDIN π
The standard input shall be used if no file operand is specified, and shall be used if the file operand is '-' and the implementation treats the '-' as meaning standard input. Otherwise, the standard input shall not be used. See the INPUT FILES section. π
π§ INPUT FILES π§
If the -c option is specified, the input file can contain arbitrary data β go wild. Otherwise, the input file shall be a text file.
π ENVIRONMENT VARIABLES π
The following environment variables shall affect the execution of tail:
LANGβ provide a default value for the internationalization variables that are unset or null. (See the Base Definitions volume of POSIX.1β2017, Section 8.2, Internationalization Variables for the precedence of internationalization variables used to determine the values of locale categories.)LC_ALLβ if set to a non-empty string value, override the values of all the other internationalization variables.LC_CTYPEβ determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as opposed to multi-byte characters in arguments and input files).LC_MESSAGESβ determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.NLSPATHβ determine the location of message catalogs for the processing ofLC_MESSAGES.
β ASYNCHRONOUS EVENTS β
Default.
π STDOUT π
The designated portion of the input file shall be written to standard output. that's the whole delivery. π¦
π₯ STDERR π₯
The standard error shall be used only for diagnostic messages.
π OUTPUT FILES π
None.
π¦ EXTENDED DESCRIPTION π¦
None.
π EXIT STATUS π
The following exit values shall be returned:
0β Successful completion. slay.>0β An error occurred. π
π«Ά CONSEQUENCES OF ERRORS π«Ά
Default.
The following sections are informative.
π APPLICATION USAGE π
The -c option should be used with caution when the input is a text file containing multi-byte characters β it may produce output that does not start on a character boundary. so like, you might get half a character and honestly that's on you. π«
Although the input file to tail can be any type, the results might not be what would be expected on some character special device files, or on file types not described by the System Interfaces volume of POSIX.1β2017. Since this volume of POSIX.1β2017 does not specify the block size used when doing input, tail need not read all of the data from devices that only perform block transfers. no cap.
When using tail to process pathnames, and the -c option is not specified, it is recommended that LC_ALL β or at least LC_CTYPE and LC_COLLATE β are set to POSIX or C in the environment, since pathnames can contain byte sequences that do not form valid characters in some locales, in which case the utility's behavior would be undefined. In the POSIX locale each byte is a valid single-byte character, and therefore this problem is avoided. consider this your PSA. π’
πΈ EXAMPLES πΈ
The -f option can be used to monitor the growth of a file that is being written by some other process. For example, this command:
tail -f fred
prints the last ten lines of the file fred, followed by any lines that are appended to fred between the time tail is initiated and killed. β¨
As another example, this command:
tail -f -c 15 fred
prints the last 15 bytes of the file fred, followed by any bytes that are appended to fred between the time tail is initiated and killed.
π RATIONALE π
This version of tail was created to allow conformance to the Utility Syntax Guidelines. The historical -b option was omitted because of the general non-portability of block-sized units of text. The -c option historically meant βcharactersβ, but this volume of POSIX.1β2017 indicates that it means βbytesβ. This was selected to allow reasonable implementations when multi-byte characters are possible; it was not named -b to avoid confusion with the historical -b. iykyk.
The origin of counting both lines and bytes is 1, matching all widespread historical implementations. Hence tail -n +0 is not conforming usage because it attempts to output line zero; but note that tail -n 0 does conform, and outputs nothing. wild, but true.
Earlier versions of this standard allowed the following forms in the SYNOPSIS:
tail -[number][b|c|l][f] [file]
tail +[number][b|c|l][f] [file]
These forms are no longer specified by POSIX.1β2008, but may be present in some implementations. so if you see them in the wild, that's why. π΅
The restriction on the internal buffer is a compromise between the historical System V implementation of 4096 bytes and the BSD 32768 bytes.
The -f option has been implemented as a loop that sleeps for 1 second and copies any bytes that are available. This is sufficient, but if more efficient methods of determining when new data are available are developed, implementations are encouraged to use them. (devs: the floor is yours. π
)
Historical documentation indicates that tail ignores the -f option if the input file is a pipe (pipe and FIFO on systems that support FIFOs). On BSD-based systems, this has been true; on System V-based systems, this was true when input was taken from standard input, but it did not ignore the -f flag if a FIFO was named as the file operand. Since the -f option is not useful on pipes and all historical implementations ignore -f if no file operand is specified and standard input is a pipe, this volume of POSIX.1β2017 requires this behavior. However, since the -f option is useful on a FIFO, this volume of POSIX.1β2017 also requires that if a FIFO is named, the -f option shall not be ignored. Earlier versions of this standard did not state any requirement for the case where no file operand is specified and standard input is a FIFO. The standard has been updated to reflect current practice, which is to treat this case the same as a pipe on standard input. Although historical behavior does not ignore the -f option for other file types, this is unspecified so that implementations are allowed to ignore the -f option if it is known that the file cannot be extended. whew. history lesson complete. π
π¦ FUTURE DIRECTIONS π¦
None.
π SEE ALSO π
head- The Base Definitions volume of POSIX.1β2017, Chapter 8, Environment Variables, Section 12.2, Utility Syntax Guidelines
π COPYRIGHT π
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
and that's the whole page, bestie!! π no notes, ate and left no crumbs, you now know tail better than most people know themselves. this one came from the fine folks at IEEE / The Open Group, dated 2017, and it lives in the manual as TAIL(1POSIX). mwah. π
π¦ where this page comes from
- debian bookworm: manpages-posix 2017a-2 Β· Other
- debian trixie: manpages-posix 2017a-2 Β· Other
- ubuntu jammy: manpages-posix 2017a-2 Β· Other
- ubuntu noble: manpages-posix 2017a-2 Β· Other
- ubuntu resolute: manpages-posix 2017a-2build1 Β· Other
- ubuntu stonking: manpages-posix 2017a-2.1 Β· Other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms