Every day a Linux command (one)--NL command

Source: Internet
Author: User

The NL command is used in a Linux system to calculate the line number of a file. NL can be the output of the file content automatically add line number, its default result and cat-n a bit different, NL can do more than the line number display design, including the number of digits and whether or not automatically 0 and so on.

1. Command format:

NL [Options] [file]

2. Command parameters:

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

-B A indicates that line numbers are also listed, whether or not they are blank (similar to cat-n)

-B T If there is a blank line, do not list the line number (default) for the empty row

-N Lists the method of line number representation, there are three main types:

The-n-Ln line number is displayed on the left side of the screen

The-n RN line number is displayed on the very right of its own field and does not add 0

-N RZ line number is displayed on the very right of its own field, plus 0

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

-P does not restart calculation 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 unloaded in the 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 individually for headers, body, and footer sections (for example, header and footer lines can be computed however the text line cannot).

4. Usage examples:

Example one: Listing 001.log content with NL

Command:

NL 001.log Blank line does not add line number, Cat command will;

Example two: Using NL to list the contents of 001.log, empty cells also add line number

Command:

Nl-b a 001.log "-B A" adds up to be a complete set of parameters

Example three: Let the line number in front of the automatic 0, unified output format

Command:

Nl-b a-n rz 001.log or nl-n rz 001.log, or nl-n rz-w digit digit 001.log, line number default is six bit, can be adjusted.

  

  

Every day a Linux command (one)--NL command

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.