TAIL(1)                    POSIX Programmer's Manual                   TAIL(1)



PPRROOLLOOGG
       This manual page is part of the POSIX Programmer's Manual.  The OS
       implementation of this interface may differ (consult the corresponding
       OS manual page for details of OS behavior), or the interface may not be
       implemented on OS.


NNAAMMEE
       tail -- copy the last part of a file

SSYYNNOOPPSSIISS
       tail [[-f]] [[-c _n_u_m_b_e_r|-n _n_u_m_b_e_r]] [[_f_i_l_e]]

DDEESSCCRRIIPPTTIIOONN
       The _t_a_i_l utility shall copy its input file to the standard output
       beginning at a designated place.

       Copying shall begin at the point in the file indicated by the --cc _n_u_m_b_e_r
       or --nn _n_u_m_b_e_r options. The option-argument _n_u_m_b_e_r shall be counted in
       units of lines or bytes, according to the options --nn and --cc.  Both line
       and byte counts start from 1.

       Tails relative to the end of the file may be saved in an internal
       buffer, and thus may be limited in length. Such a buffer, if any, shall
       be no smaller than {LINE_MAX}*10 bytes.

OOPPTTIIOONNSS
       The _t_a_i_l utility shall conform to the Base Definitions volume of
       POSIX.1-2008, _S_e_c_t_i_o_n _1_2_._2, _U_t_i_l_i_t_y _S_y_n_t_a_x _G_u_i_d_e_l_i_n_e_s, except that ''++''
       may be recognized as an option delimiter as well as ''--''.

       The following options shall be supported:

       --cc _n_u_m_b_e_r The application shall ensure that the _n_u_m_b_e_r option-argument
                 is a decimal integer, optionally including a sign.  The sign
                 shall affect the location in the file, measured in bytes, to
                 begin the copying:

                        +-----+----------------------------------------+
                        |SSiiggnn |             CCooppyyiinngg SSttaarrttss             |
                        +-----+----------------------------------------+
                        | +   | Relative to the beginning of the file. |
                        | -   | Relative to the end of the file.       |
                        |_n_o_n_e | Relative to the end of the file.       |
                        +-----+----------------------------------------+
                 The application shall ensure that if the sign of the _n_u_m_b_e_r
                 option-argument is ''++'', the _n_u_m_b_e_r option-argument is a non-
                 zero decimal integer.

                 The origin for counting shall be 1; that is, --cc +1 represents
                 the first byte of the file, --cc -1 the last.

       --ff        If the input file is a regular file or if the _f_i_l_e operand
                 specifies a FIFO, do not terminate after the last line of the
                 input file has been copied, but read and copy further bytes
                 from the input file when they become available. If no _f_i_l_e
                 operand is specified and standard input is a pipe or FIFO,
                 the --ff option shall be ignored. If the input file is not a
                 FIFO, pipe, or regular file, it is unspecified whether or not
                 the --ff option shall be ignored.

       --nn _n_u_m_b_e_r This option shall be equivalent to --cc _n_u_m_b_e_r, except the
                 starting location in the file shall be measured in lines
                 instead of bytes. The origin for counting shall be 1; that
                 is, --nn +1 represents the first line of the file, --nn -1 the
                 last.

       If neither --cc nor --nn is specified, --nn 10 shall be assumed.

OOPPEERRAANNDDSS
       The following operand shall be supported:

       _f_i_l_e      A pathname of an input file. If no _f_i_l_e operand is specified,
                 the standard input shall be used.

SSTTDDIINN
       The standard input shall be used if no _f_i_l_e operand is specified, and
       shall be used if the _f_i_l_e operand is ''--'' and the implementation treats
       the ''--'' as meaning standard input.  Otherwise, the standard input shall
       not be used.  See the INPUT FILES section.

IINNPPUUTT FFIILLEESS
       If the --cc option is specified, the input file can contain arbitrary
       data; otherwise, the input file shall be a text file.

EENNVVIIRROONNMMEENNTT VVAARRIIAABBLLEESS
       The following environment variables shall affect the execution of _t_a_i_l:

       _L_A_N_G      Provide a default value for the internationalization
                 variables that are unset or null. (See the Base Definitions
                 volume of POSIX.1-2008, _S_e_c_t_i_o_n _8_._2, _I_n_t_e_r_n_a_t_i_o_n_a_l_i_z_a_t_i_o_n
                 _V_a_r_i_a_b_l_e_s for the precedence of internationalization
                 variables used to determine the values of locale categories.)

       _L_C___A_L_L    If set to a non-empty string value, override the values of
                 all the other internationalization variables.

       _L_C___C_T_Y_P_E  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).

       _L_C___M_E_S_S_A_G_E_S
                 Determine the locale that should be used to affect the format
                 and contents of diagnostic messages written to standard
                 error.

       _N_L_S_P_A_T_H   Determine the location of message catalogs for the processing
                 of _L_C___M_E_S_S_A_G_E_S.

AASSYYNNCCHHRROONNOOUUSS EEVVEENNTTSS
       Default.

SSTTDDOOUUTT
       The designated portion of the input file shall be written to standard
       output.

SSTTDDEERRRR
       The standard error shall be used only for diagnostic messages.

OOUUTTPPUUTT FFIILLEESS
       None.

EEXXTTEENNDDEEDD DDEESSCCRRIIPPTTIIOONN
       None.

EEXXIITT SSTTAATTUUSS
       The following exit values shall be returned:

        0    Successful completion.

       >0    An error occurred.

CCOONNSSEEQQUUEENNCCEESS OOFF EERRRROORRSS
       Default.

       _T_h_e _f_o_l_l_o_w_i_n_g _s_e_c_t_i_o_n_s _a_r_e _i_n_f_o_r_m_a_t_i_v_e_.

AAPPPPLLIICCAATTIIOONN UUSSAAGGEE
       The --cc 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.

       Although the input file to _t_a_i_l 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-2008. Since this volume of POSIX.1-2008 does not specify the
       block size used when doing input, _t_a_i_l need not read all of the data
       from devices that only perform block transfers.

EEXXAAMMPPLLEESS
       The --ff option can be used to monitor the growth of a file that is being
       written by some other process. For example, the command:

           ttaaiill --ff ffrreedd

       prints the last ten lines of the file ffrreedd, followed by any lines that
       are appended to ffrreedd between the time _t_a_i_l is initiated and killed. As
       another example, the command:

           ttaaiill --ff --cc 1155 ffrreedd

       prints the last 15 bytes of the file ffrreedd, followed by any bytes that
       are appended to ffrreedd between the time _t_a_i_l is initiated and killed.

RRAATTIIOONNAALLEE
       This version of _t_a_i_l was created to allow conformance to the Utility
       Syntax Guidelines. The historical --bb option was omitted because of the
       general non-portability of block-sized units of text. The --cc option
       historically meant ``characters'', but this volume of POSIX.1-2008
       indicates that it means ``bytes''. This was selected to allow
       reasonable implementations when multi-byte characters are possible; it
       was not named --bb to avoid confusion with the historical --bb.

       The origin of counting both lines and bytes is 1, matching all
       widespread historical implementations. Hence _t_a_i_l --nn +0 is not
       conforming usage because it attempts to output line zero; but note that
       _t_a_i_l --nn 0 does conform, and outputs nothing.

       Earlier versions of this standard allowed the following forms in the
       SYNOPSIS:

           ttaaiill --[[number]][[b|c|l]][[f]] [[_f_i_l_e]]
           tail +[[number]][[b|c|l]][[f]] [[_f_i_l_e]]

       These forms are no longer specified by POSIX.1-2008, but may be present
       in some implementations.

       The restriction on the internal buffer is a compromise between the
       historical System V implementation of 4096 bytes and the BSD 32768
       bytes.

       The --ff 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.

       Historical documentation indicates that _t_a_i_l ignores the --ff 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 --ff flag if a FIFO was named as the _f_i_l_e operand. Since the
       --ff option is not useful on pipes and all historical implementations
       ignore --ff if no _f_i_l_e operand is specified and standard input is a pipe,
       this volume of POSIX.1-2008 requires this behavior. However, since the
       --ff option is useful on a FIFO, this volume of POSIX.1-2008 also
       requires that if a FIFO is named, the --ff option shall not be ignored.
       Earlier versions of this standard did not state any requirement for the
       case where no _f_i_l_e 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 --ff option for other file types,
       this is unspecified so that implementations are allowed to ignore the
       --ff option if it is known that the file cannot be extended.

FFUUTTUURREE DDIIRREECCTTIIOONNSS
       None.

SSEEEE AALLSSOO
       _h_e_a_d

       The Base Definitions volume of POSIX.1-2008, _C_h_a_p_t_e_r _8, _E_n_v_i_r_o_n_m_e_n_t
       _V_a_r_i_a_b_l_e_s, _S_e_c_t_i_o_n _1_2_._2, _U_t_i_l_i_t_y _S_y_n_t_a_x _G_u_i_d_e_l_i_n_e_s

CCOOPPYYRRIIGGHHTT
       Portions of this text are reprinted and reproduced in electronic form
       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
       -- Portable Operating System Interface (POSIX), The Open Group Base
       Specifications Issue 7, Copyright (C) 2013 by the Institute of
       Electrical and Electronics Engineers, Inc and The Open Group.  (This is
       POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) 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.unix.org/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 .



IEEE/The Open Group                  2013                              TAIL(1)
