NL
"function description": the NL command Linux the line number in the system used to calculate the file . NL can automatically add a line number to the output file content! The default result is a bit different from Cat-n, NL can make the line number more display design, including the number of digits and whether auto-completion 0 and so on.
"Syntax format": nl [Options] ... [File] ...
"Option Parameters":
- B: Specifies the way the line number is specified, mainly in two ways:
-B A: Indicates that the line number (similar to cat-n) is also listed, whether or not it is a blank line;
-B T: If there is a blank line, the empty line does not list the row number (default);
-N: List the method of line number representation, there are three main kinds:
-N LN: The line number is displayed at the left of the screen;
-N RN: The line number is displayed on the very right of its own field and does not add 0;
-N RZ: line number in its own field to the right of the display, and add 0;
-W: The number of digits occupied by the line number field.
- P : The calculation does not start again at the logical delimiter.
"Practice Actions":
The NL command reads the File parameter (standard input by default), computes the line number in the input, and writes the computed line number to standard output. In the output, the NL command calculates the left line based on the flags that you specify on the command line. The input text must be written in a logical page. Each logical page has a header, a body, and a footer section (which can have an empty section). Unless you use the-P flag, the NL command re-sets the line number where each logical page begins. Row calculation flags can be set separately for header, body, and footer sections (for example, header and footer rows can be computed, but text lines cannot).
instance One : Use NL to list log2012.log content
Command:
NL Log2012.log
Output:
[Email protected] test]# NL Log2012.log
1 2012-01
2 2012-02
3 ======
[Email protected] test]#
Description
Blank lines in the file, NL does not add line numbers
Example Two : The contents of Log2012.log are listed in NL and the line number is also added to the empty bank
Command:
Nl-b a Log2012.log
Output:
[Email protected] test]# Nl-b a Log2012.log
1 2012-01
2 2012-02
3
4
5 ======
[Email protected] test]#
Example 3 : Allow the line number to be preceded by 0, unified output format
[Email protected] test]# nl-b a-n RZ log2014.log
000001 2014-01
000002 2014-02
000003 2014-03
000004 2014-04
000005 2014-05
000006 2014-06
000007 2014-07
000008 2014-08
000009 2014-09
000010 2014-10
000011 2014-11
000012 2014-12
000013 =======
[Email protected] test]# nl-b a-n rz-w 3 Log2014.log
001 2014-01
002 2014-02
003 2014-03
004 2014-04
005 2014-05
006 2014-06
007 2014-07
008 2014-08
009 2014-09
010 2014-10
011 2014-11
012 2014-12
013 =======
Description
nl-b a-n RZ the command line number defaults to six bits, and the number of bits to adjust can be adjusted to 3 bits with the parameter-W 3.
This article is from the "Cornerboy" blog, make sure to keep this source http://cornerboy.blog.51cto.com/10012663/1651580
Linux Small white-basic command-NL