Linux NL command

Source: Internet
Author: User

In a Linux system, the NL command is used to calculate the line number of a 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 do a lot of display design, including the number of digits and whether the automatic completion of 0 and other functions.

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 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: The line number is displayed on the very right of the field, plus 0;

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

-P does not restart the calculation at the logical delimiter.


command example:

1. Use NL to list the contents of/etc/issue

[[email protected] zdw]# nl/etc/issue 1 CentOS release 6.5 (Final) 2 Kernel \ R on a \m this file actually has three lines and the third action is blank, so NL will not add  Upstream number, if you want to add line numbers, you can use the-b a parameter [[email protected] zdw]# nl-b a/etc/issue 1 CentOS release 6.5 (Final) 2 Kernel \ R on an \m 3

2. Let the line number in front of the auto-fill 0

[Email protected] zdw]# nl-b a-n rz/etc/issue000001 CentOS release 6.5 (Final) 000002 Kernel \ r on a \m000003 automatically in its own field     Place 0, the default field is 6 digits, if changed to 3 bits, as follows: [[email protected] zdw]# nl-b a-n rz-w 3/etc/issue001 CentOS release 6.5 (Final) 002 Kernel \ r on an \m003


Learn from:

Brother Bird's Linux private cuisine

This article is from the blog "Write to Yourself", so be sure to keep this source http://zhaodongwei.blog.51cto.com/4233742/1765332

Linux 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.