Every day, a linux command (11): nl command link: A linux command (1): ls command every day (2): cd command http://www.2cto.com/ OS /201210/163050.html#a linuxcommand every day ..
One linux command every day (11): nl command link: One linux command every day (1): ls command http://www.2cto.com/os/201210/163049.html ; One linux command every day (2): cd command http://www.2cto.com/os/201210/163050.html ; One linux command every day (3): pwd command http://www.2cto.com/os/201210/163462.html ; One linux command every day (4): mkdir command http://www.2cto.com/os/201210/163463.html ; One linux command every day (5): rm command http://www.2cto.com/os/201210/163662.html ; One linux command (6) every day: rmdir command http://www.2cto.com/os/201210/164017.html ; One linux command (7) every day: mv command http://www.2cto.com/os/201210/164247.html ; One linux command every day (8): cp command http://www.2cto.com/os/201210/164254.html ; One linux command every day (9): touch Command http://www.2cto.com/os/201211/165699.html ; One linux command every day (10): cat command http://www.2cto.com/os/201211/165989.html The nl command is used in linux to calculate the row number in the file. Nl can automatically add the row number to the output file content! The default result is a little different from cat-n. nl can compare multiple display designs of the row number, including the number of digits and whether to automatically complete 0. Www.2cto.com 1. command format: nl [option]... [file]... 2. command parameter:-B: specifies the row number. There are two main methods:-B a: indicates that the row number is also listed (similar to cat-n), regardless of whether the row is empty or not ); -B t: if there are blank rows, do not list the row number (default value) for the empty row;-n: list the methods represented by the row number. There are three main methods:-n ln: the row number is displayed on the leftmost side of the screen;-n rn: The row number is displayed on the rightmost side of its own column without 0;-n rz: the row number is displayed in the rightmost of its own column, and 0 is added;-w: The number of digits occupied by the column number. -P does not start computing again at the logical delimiters. 3. command function: The nl command reads the File parameter (standard input by default), calculates the row number in the input, and writes the computed row number to the standard output. In the output, the nl command calculates the left line based on the flag specified in the command line. The input text must be written on the logic page. Each logic page has a header, body, and footer section (you can leave a blank section ). Unless the-p flag is used, the nl command resets the row number at the beginning of each logic page. You can set a line calculation flag for the header, body, and footer sections separately (for example, the header and footer rows can be calculated, but the text rows cannot ). 4. use instance: instance 1: Use nl to list log2012.log content command: nl log2012.log output: [root @ localhost test] # nl log2012.log 1 2012-01 2 2012-02 3 ===== [root @ localhost test] # Note: blank lines in the file, nl does not add row number instance 2: Use nl to list the content of log2012.log, and add the line number command "nl-B a log2012.log" to the blank line. output: [root @ localhost test] # nl-B a log2012.log 1 2012-01 2 2012-02 3 4 5 ===== [root @ localhost test] # instance 3: set 0 to the front of the line number and output the command in a unified format: Output: [root @ localhost test] # nl-B a-n rz log2014.log 00000 1 2014-01000002 2014-02000003 2014-03000004 2014-04000005 2014-05000006 2014-06000007 2014-07000008 2014-08000009 2014-09000010 2014-10000011 2014-11000012 = === [root @ localhost test] # nl-B a-n rz-w 3 log2014.log 001 2014-01002 2014-02003 2014-03004 2014-04005 2014-05006-2014- 06007 2014-07008 2014-08009 2014-09010 2014-10011 2014-11012 2014-12013 ====== Note: the line number of the nl-B a-n rz command is six by default. To adjust the number of digits, add the parameter-w 3 to 3.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.