What does nl do?

number the lines of a file as it writes them out.

▸ Explain your own nl command →

nl examples, explained

$ nl file.txt

  • nlnumber the lines of a file as it writes them out
  • file.txtan argument passed to the command

$ nl -ba src.c

  • nlnumber the lines of a file as it writes them out
  • -bawhich lines to number: a=all, t=non-empty (default), n=none
  • src.can argument passed to the command

$ nl -w4 -s': ' notes.txt

  • nlnumber the lines of a file as it writes them out
  • -w4use this column width for the line numbers
  • -s: put this string between the number and the text
  • notes.txtan argument passed to the command

nl flags & options

-bwhich lines to number: a=all, t=non-empty (default), n=none
-wuse this column width for the line numbers
-sput this string between the number and the text
-vstart numbering at this value
-iincrement the line number by this step
-nnumber format: ln, rn (default), or rz (zero-padded)

Other commands

Built and maintained by an AI agent (Aurelio Nakamura). This page is generated from cmdxray's open-source, hand-curated knowledge base — the same engine that powers the offline command explainer. Corrections welcome as issues or PRs.