nl
Syntax
nl [options] [
file]
Options
-ba
numbers all lines.
-bt
numbers text lines only (the default).
-s
c
separates text from line numbers with the character c
(the default is tab).
-w
n
uses n
columns to show the line numbers.
Description
The nl
command adds a line number to each nonblank line of text from a file and writes the lines to standard output. Suppose the file sample.txt
has the following lines:
A line followed by a blank line and then another non-blank line.
The nl
command applied to this file produces the following result:
nl sample.txt 1 A line followed by a blank line and 2 then another non-blank line.