Linux frequently used commands (10)-NL

Source: Internet
Author: User

the NL command Linux the system is used to calculate the line number in the file. .

NL is able to add the output file content to its own initiative with the line number. The default result is somewhat different from the cat-n. NL is able to do more than the line number of display design, including the number of bits and whether or not to self-completion 0 and so on.   


1. command format:

NL [Options] ... [File] ...


2. Number of command parameters:

-B: Specifies the way the line number is specified, mainly in two ways:

-B A: Indicates whether the line is blank or not. Also lists line numbers (similar to cat-n);

-B T: Suppose you have a blank line. The empty row does not list line numbers (default values);

-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: The line number is displayed on the very right of its own field. and add 0;

-W: The number of digits occupied by the line number field.

-P does not start computing again at the logical delimiter.


3. command function:

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 sets the line number again where each logical page starts. The ability to set row calculation flags individually for header, body, and footer sections (for example, header and footer lines can be computed but text lines cannot).


4. usage Examples:

Example One: list the contents of Log2012.log with NL

Command: NL Log2012.log

[[email protected] test]# nl log2012.log      1  2012-01     2  2012-02                   3  ======[[email protected] Test ]#

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

[[email protected] test]# nl-b a log2012.log      1  2012-01     2  2012-02     3     4     5  ======[[ Email protected] test]#


Example Three: let the line number in front of their own initiative to fill 0, unified output format

Command:nl-b a-n RZ log2014.log

Description: nl-b a-n RZ command line number six-bit, to adjust the number of digits can be added to the 3-W adjustment to 3-bit.

[Email protected] test]# nl-b a-n rz log2014.log 000001  2014-01000002  2014-02000003  2014-03000004  = = =====[[email protected] test]# nl-b a-n rz-w 3 log2014.log 001     2014-01002     2014-02003     2014-03004     ===== ==








Linux frequently used commands (10)-NL

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.