nl
A utility for numbering lines, either from a file, or from stdin
.
More information: https://www.gnu.org/software/coreutils/nl.
-
Number non-blank lines in a file:
nl {{path/to/file}}
-
Read from
stdout
:
cat {{path/to/file}} | nl {{options}} -
-
Number only the lines with printable text:
nl -t {{path/to/file}}
-
Number all lines including blank lines:
nl -b a {{path/to/file}}
-
Number only the body lines that match a basic regular expression (BRE) pattern:
nl -b p'FooBar[0-9]' {{path/to/file}}
License and Disclaimer
The content on this page is copyright © 2014—present the tldr-pages team and contributors.This page is used with permission under Creative Commons Attribution 4.0 International License.
While we do attempt to make sure content is accurate, there isn't a warranty of any kind.