1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-08-04 15:35:34 +02:00
tldr/pages/linux/nl.md
Vitor Henrique 2df868402a
common/nl: update page; linux/nl: add page (#12163)
* common/nl: update page; linux/nl: add page

---------

Co-authored-by: Sebastiaan Speck <12570668+sebastiaanspeck@users.noreply.github.com>
Co-authored-by: Juri Dispan <juri.dispan@posteo.net>
2024-02-09 19:22:51 +05:30

967 B

nl

Number lines from a file or from stdin. More information: https://manned.org/nl.1p.

  • Number non-blank lines in a file:

nl {{path/to/file}}

  • Read from stdin:

{{command}} | nl -

  • Number [a]ll [b]ody lines including blank lines or do not [n]umber [b]ody lines:

nl --body-numbering {{a|n}} {{path/to/file}}

  • Number only the [b]ody lines that match a basic regular expression (BRE) [p]attern:

nl --body-numbering p'FooBar[0-9]' {{path/to/file}}

  • Use a specific [i]ncrement for line numbering:

nl --line-increment {{increment}} {{path/to/file}}

  • Specify the line numbering format to [r]ight or [l]eft justified, keeping leading [z]eros or [n]ot:

nl --number-format {{rz|ln|rn}}

  • Specify the line numbering's width (6 by default):

nl --number-width {{col_width}} {{path/to/file}}

  • Use a specific string to separate the line numbers from the lines (TAB by default):

nl --number-separator {{separator}} {{path/to/file}}