NL(1)                      POSIX Programmer's Manual                     NL(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
       nl -- line numbering filter

SSYYNNOOPPSSIISS
       nl [[-p]] [[-b _t_y_p_e]] [[-d _d_e_l_i_m]] [[-f _t_y_p_e]] [[-h _t_y_p_e]] [[-i _i_n_c_r]] [[-l _n_u_m]]
           [[-n _f_o_r_m_a_t]] [[-s _s_e_p]] [[-v _s_t_a_r_t_n_u_m]] [[-w _w_i_d_t_h]] [[_f_i_l_e]]

DDEESSCCRRIIPPTTIIOONN
       The _n_l utility shall read lines from the named _f_i_l_e or the standard
       input if no _f_i_l_e is named and shall reproduce the lines to standard
       output. Lines shall be numbered on the left. Additional functionality
       may be provided in accordance with the command options in effect.

       The _n_l utility views the text it reads in terms of logical pages. Line
       numbering shall be reset at the start of each logical page. A logical
       page consists of a header, a body, and a footer section. Empty sections
       are valid. Different line numbering options are independently available
       for header, body, and footer (for example, no numbering of header and
       footer lines while numbering blank lines only in the body).

       The starts of logical page sections shall be signaled by input lines
       containing nothing but the following delimiter characters:

                              +-----------+------------+
                              |   LLiinnee    |  SSttaarrtt ooff  |
                              +-----------+------------+
                              |\:\:\:     | Header     |
                              |\:\:       | Body       |
                              |\:         | Footer     |
                              +-----------+------------+
       Unless otherwise specified, _n_l shall assume the text being read is in a
       single logical page body.

OOPPTTIIOONNSS
       The _n_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.  Only one file
       can be named.

       The following options shall be supported:

       --bb _t_y_p_e   Specify which logical page body lines shall be numbered.
                 Recognized _t_y_p_e_s and their meaning are:

                 aa       Number all lines.

                 tt       Number only non-empty lines.

                 nn       No line numbering.

                 pp_s_t_r_i_n_g Number only lines that contain the basic regular
                         expression specified in _s_t_r_i_n_g.

                 The default _t_y_p_e for logical page body shall be tt (text lines
                 numbered).

       --dd _d_e_l_i_m  Specify the delimiter characters that indicate the start of a
                 logical page section. These can be changed from the default
                 characters ""\\::"" to two user-specified characters. If only one
                 character is entered, the second character shall remain the
                 default character ''::''.

       --ff _t_y_p_e   Specify the same as bb _t_y_p_e except for footer. The default for
                 logical page footer shall be nn (no lines numbered).

       --hh _t_y_p_e   Specify the same as bb _t_y_p_e except for header. The default
                 _t_y_p_e for logical page header shall be nn (no lines numbered).

       --ii _i_n_c_r   Specify the increment value used to number logical page
                 lines. The default shall be 1.

       --ll _n_u_m    Specify the number of blank lines to be considered as one.
                 For example, --ll 22 results in only the second adjacent blank
                 line being numbered (if the appropriate --hh aa, --bb aa, or --ff aa
                 option is set). The default shall be 1.

       --nn _f_o_r_m_a_t Specify the line numbering format. Recognized values are: llnn,
                 left justified, leading zeros suppressed; rrnn, right
                 justified, leading zeros suppressed; rrzz, right justified,
                 leading zeros kept. The default _f_o_r_m_a_t shall be rrnn (right
                 justified).

       --pp        Specify that numbering should not be restarted at logical
                 page delimiters.

       --ss _s_e_p    Specify the characters used in separating the line number and
                 the corresponding text line. The default _s_e_p shall be a
                 <tab>.

       --vv _s_t_a_r_t_n_u_m
                 Specify the initial value used to number logical page lines.
                 The default shall be 1.

       --ww _w_i_d_t_h  Specify the number of characters to be used for the line
                 number. The default _w_i_d_t_h shall be 6.

OOPPEERRAANNDDSS
       The following operand shall be supported:

       _f_i_l_e      A pathname of a text file to be line-numbered.

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
       The input file shall be a text file.

EENNVVIIRROONNMMEENNTT VVAARRIIAABBLLEESS
       The following environment variables shall affect the execution of _n_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_O_L_L_A_T_E
                 Determine the locale for the behavior of ranges, equivalence
                 classes, and multi-character collating elements within
                 regular expressions.

       _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), the behavior of character classes within regular
                 expressions, and for deciding which characters are in
                 character class ggrraapphh (for the --bb tt, --ff tt, and --hh tt options).

       _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 standard output shall be a text file in the following format:

           ""%%ss%%ss%%ss"",, <<_l_i_n_e _n_u_m_b_e_r>, <_s_e_p_a_r_a_t_o_r>, <_i_n_p_u_t _l_i_n_e>

       where <_l_i_n_e _n_u_m_b_e_r> is one of the following numeric formats:

       %6d       When the rrnn format is used (the default; see --nn).

       %06d      When the rrzz format is used.

       %-6d      When the llnn format is used.

       <empty>   When line numbers are suppressed for a portion of the page;
                 the <_s_e_p_a_r_a_t_o_r> is also suppressed.

       In the preceding list, the number 6 is the default width; the --ww option
       can change this value.

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
       In using the --dd _d_e_l_i_m option, care should be taken to escape characters
       that have special meaning to the command interpreter.

EEXXAAMMPPLLEESS
       The command:

           nnll --vv 1100 --ii 1100 --dd \\!!++ ffiillee11

       numbers _f_i_l_e_1 starting at line number 10 with an increment of 10. The
       logical page delimiter is ""!!++"".  Note that the ''!!''  has to be escaped
       when using _c_s_h as a command interpreter because of its history
       substitution syntax.  For _k_s_h and _s_h the escape is not necessary, but
       does not do any harm.

RRAATTIIOONNAALLEE
       None.

FFUUTTUURREE DDIIRREECCTTIIOONNSS
       None.

SSEEEE AALLSSOO
       _p_r

       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                                NL(1)
