LinuxCommandLibrary

number

Number lines in a file

SYNOPSIS


nl [OPTION]... [FILE]...

PARAMETERS

-b TYPE, --body-numbering=TYPE
    Selects numbering style for body lines. TYPE can be a (all lines), t (non-empty lines, default), n (no numbering), or pREGEX (lines matching regex).

-f TYPE, --footer-numbering=TYPE
    Selects numbering style for footer lines. Same TYPE options as for body lines.

-h TYPE, --header-numbering=TYPE
    Selects numbering style for header lines. Same TYPE options as for body lines.

-l N, --line-increment=N
    Specifies the number of lines to count before numbering again (e.g., number every Nth line).

-s STRING, --separator=STRING
    Specifies the string appended to the line number, separating it from the text line. Default is a tab character.

-v N, --starting-line-number=N
    Sets the starting line number for the first line. Default is 1.

-w N, --width=N
    Sets the number of characters to use for line numbers. Default is 6.

-n FORMAT, --number-format=FORMAT
    Inserts line numbers according to FORMAT. Options include ln (left justified, no leading zeros), rn (right justified, no leading zeros), rz (right justified, leading zeros, default).

-p, --no-renumber
    Do not renumber at logical page breaks (defined by section delimiters).

-d CC, --section-delimiter=CC
    Uses CC (two characters) as the logical page delimiter characters instead of the default \:\:.

--help
    Displays a help message and exits.

--version
    Outputs version information and exits.

DESCRIPTION

The command 'number' is not a standard, standalone Linux command. This analysis assumes the user was referring to nl (number lines), a common utility for adding line numbers to text files.

The nl command numbers lines of files, writing the result to standard output. It is highly useful for displaying source code, log files, or any text where line numbers are beneficial for reference. It can number all lines, non-empty lines, or only lines that match a regular expression. Various formatting options are available, such as number width, leading zeros, and different numbering styles.

CAVEATS

The primary function of nl is line numbering, not general numeric processing. For generating sequences of numbers or performing arithmetic operations, commands like seq or scripting with awk are more suitable. While nl is part of GNU coreutils and widely available on Linux, it's specific to text line manipulation.

CLARIFICATION ON 'NUMBER' COMMAND

The command 'number' is not a standard, standalone Linux command found in typical distributions. This document has provided information based on the highly related and commonly used nl command, which directly deals with assigning and formatting numbers (line numbers) to text content. If you were looking for general numeric processing or sequence generation, please consider commands like seq or scripting capabilities within tools like awk or shell arithmetic.

HISTORY

The nl command is a standard Unix utility, part of the POSIX standard. Its functionality has been stable for many decades. It is included in GNU coreutils, which provides the standard utilities for Linux systems, ensuring its widespread availability and consistent behavior.

SEE ALSO

cat(1), grep(1), sed(1), awk(1), seq(1)

Copied to clipboard