0

From nl manual:

...

-f, --footer-numbering=STYLE
          use STYLE for numbering footer lines

-h, --header-numbering=STYLE
       use STYLE for numbering header lines

...

Can you provide an example of usage of the -f and -h option? What is considered as being a footer or header?

3

It looks like you're reading the manpage of GNU nl. The full documentation in info nl (or online) describes it more completelye:

nl decomposes its input into (logical) page sections; by default, the line number is reset to 1 at each logical page section. nl treats all of the input files as a single document; it does not reset line numbers or logical pages between files.

A logical page consists of three sections: header, body, and footer. Any of the sections can be empty. Each can be numbered in a different style from the others.

The beginnings of the sections of logical pages are indicated in the input file by a line containing exactly one of these delimiter strings:

\:\:\:
start of header;

\:\:
start of body;

\:
start of footer.

The two characters from which these strings are made can be changed from \ and : via options (see below), but the pattern and length of each string cannot be changed.

A section delimiter is replaced by an empty line on output. Any text that comes before the first section delimiter string in the input file is considered to be part of a body section, so nl treats a file that contains no section delimiters as a single body section.

Or, similarly from the POSIX spec:

The nl 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:

Line                           Start of
\:\:\:                         Header
\:\:                           Body
\:                             Footer

An example:

% printf "\\:\\:\n%s\n\\:\nfooter\n" {a..c} | nl

     1  a

       footer

     1  b

       footer

     1  c

       footer
% printf "\\:\\:\n%s\n\\:\nfooter\n" {a..c} | nl -f a

     1  a

     1  footer

     1  b

     1  footer

     1  c

     1  footer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.