ArticleDirectory
- Parameters
- Option
-
- Example
- Tips
Add row numbers to text files
NL [Options]Files
Parameters
FilesYesNLYou need to add the text file path name of the row number for it. If there are multiple filesNLMultiple files are numbered together and output to the standard output.
Option
-B specifies the row number in two ways:
-B A indicates that the row number (similar to cat-N) is also listed no matter whether the row is empty or not)
-B T if there are blank rows, do not list the row numbers in the blank row (default)
-N: There are three methods for listing row numbers:
-N ln row number displayed on the far left of the screen
-The N rn row number is displayed on the rightmost side of its own column without adding 0
-N nz row number is displayed on the rightmost side of its own column, and 0 is added
-W: set the number of digits occupied by the row number column.
Example NL or NL-B t
$NLDemo1All people who can make an appointment2Enough food to eat3It's harder to talk and laugh than to cry.4How to get a hacker $NL-B t demo1All people who can make an appointment2Enough food to eat3It's harder to talk and laugh than to cry.4How can this problem be solved?
The row number is added by default, and the blank row is skipped.
NL-B
$NL-B A demo1All people who can make an appointment2Enough food to eat34It's harder to talk and laugh than to cry.5How can this problem be solved?
The row number is listed whether empty or not.
NL-N Rz
$NL-N rz demo000001All people who can make an appointment000002Enough food to eat000003It's harder to talk and laugh than to cry.000004How can this problem be solved?
List the row numbers and add 0 to them.
NL-n rz-W
$NL-N rz-W 3Demo001All people who can make an appointment002Enough food to eat003It's harder to talk and laugh than to cry.004How can this problem be solved?
Display the column of the row number
Tips
The NL command is similar to cat-B | cat-N, but NL is more flexible.