Forrest logo
tool overview
On this page you find all important commands for the CLI tool nl. If the command you are looking for is missing please ask our AI.

nl

The "nl" command line tool is used to number lines in a file. It is primarily used to display the content of a file with line numbers. The command is straightforward and accepts various options to customize the output.

The basic usage of "nl" is to pass a file as an argument, and it will output the contents of that file with line numbers. It is an efficient and simple way to quickly add line numbers to a file.

One of the common options with the "nl" command is "-b," which allows specifying the line numbering style. For example, "-b a" numbers all lines, "-b t" numbers non-empty lines, and "-b p" numbers no lines.

Another common option is "-s," which specifies the separator string between line number and text. This allows customization of the output format based on personal preferences or specific requirements.

The "-w" option can be used to specify the width of the line number field. This provides control over the alignment and spacing of the line numbers.

The "nl" command also supports several additional options, such as "-i" for incrementing line numbers, "-n" to number logical pages, and "-v" to specify a starting line number.

By default, "nl" prints the output on the standard output, but it also supports directing the output to a file using the ">" command.

The "nl" command is a powerful tool for pre-processing files before further manipulation or analysis. It is commonly used in scripting and batch processing scenarios.

Overall, the "nl" command line tool is a versatile utility that provides line numbering functionality with a range of options for customization and control.

List of commands for nl:

  • nl:tldr:6b4b1 nl: Number only the body lines that match a basic regular expression (BRE) pattern.
    $ nl -b p'FooBar[0-9]' ${filename}
    try on your machine
    explain this command
  • nl:tldr:7eea0 nl: Number all lines including blank lines.
    $ nl -b a ${filename}
    try on your machine
    explain this command
  • nl:tldr:9e6ce nl: Number non-blank lines in a file.
    $ nl ${filename}
    try on your machine
    explain this command
  • nl:tldr:a5471 nl: Number only the lines with printable text.
    $ nl -t ${filename}
    try on your machine
    explain this command
tool overview