NL(1)

πŸ’– NL(1) β€” numbering lines of files, but make it cute πŸ’–

okay bestie so you know that thing where you've got a file and you're like "hmm what if every line had a little number next to it"? that's nl, and it's from the General Commands Manual. she's giving very much "annotated homework" energy and honestly? we're obsessed. ✨


🌸 NAME 🌸

nl β€” number the lines of files. that's it. that's the whole job. she does one thing and she does it flawlessly.


πŸŽ€ SYNOPSIS πŸŽ€

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

yes literally that's it. options then files, the classic lil combo. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

Number lines of files.

that's the tea. she numbers. lines. of files. iconic behavior, no notes fr fr.


✨ OPTIONS ✨

  • --help β€” prints help info so you're not out here lost in the sauce πŸ™ˆ
  • -b, --body-numbering <STYLE> β€” tell her which STYLE to use when numbering the body lines
  • -d, --section-delimiter <CC> β€” use CC as the thing that separates your logical pages
  • -f, --footer-numbering <STYLE> β€” use STYLE for numbering the footer lines
  • -h, --header-numbering <STYLE> β€” use STYLE for numbering the header lines
  • -i, --line-increment <NUMBER> β€” how much the line number jumps up at each line
  • -l, --join-blank-lines <NUMBER> β€” a group of NUMBER empty lines gets counted as just one
  • -n, --number-format <FORMAT> β€” drop the line numbers in according to FORMAT

possible values are:

  • ln
  • rn
  • rz
  • -p, --no-renumber β€” do not reset the line numbers at logical pages
  • -s, --number-separator <STRING> β€” stick STRING after the (possible) line number
  • -v, --starting-line-number <NUMBER> β€” what number each logical page starts on
  • -w, --number-width <NUMBER> β€” give the line numbers NUMBER columns to live in
  • -V, --version β€” prints the version, obvi

🌈 EXTRA 🌈

STYLE is one of:

  • a β€” number all the lines
  • t β€” number only the nonempty lines (the only-valid-ones vibe)
  • n β€” number no lines, king of doing nothing
  • pBRE β€” number only the lines that contain a match for the basic regular expression, BRE

FORMAT is one of:

  • ln β€” left justified, no leading zeros
  • rn β€” right justified, no leading zeros
  • rz β€” right justified, leading zeros

πŸ’œ VERSION πŸ’œ

v(uutils coreutils) 0.12.0


πŸ”₯ EXAMPLES πŸ”₯

okay this is the part where it gets good. the tldr-pages girlies really came through with these.

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 [n]ot number [b]ody lines:

nl -b a|n path/to/file

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

nl -b p'FooBar[0-9]' path/to/file

Use a specific [i]ncrement for line numbering:

nl -i increment path/to/file

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

nl -n rz|ln|rn

Specify the line numbering's [w]idth (6 by default):

nl -w col_width path/to/file

Use a specific string to [s]eparate the line numbers from the lines (TAB by default):

nl -s separator path/to/file
bestie. listen. these examples are provided by the tldr-pages project <https://tldr.sh> under the CC BY 4.0 License. and also, because uutils is a work in progress, some examples might fail. not her fault, she's growing. 🫢

k that's the whole page, my love. this lil queen dropped on 2026-09-25 and she's running on uutils coreutils, so go forth and number some lines. you're gonna slay so hard πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈπŸ’…πŸ‘‘

πŸ“¦ where this page comes from