Simple Linux Command Line notes: NL

Source: Internet
Author: User
ArticleDirectory
    • Parameters
    • Option
    •  
    • Example
    • Tips

Add row numbers to text files

NL [Options]Files

 

Parameters

FilesYesNLYou need to add the text file path name of the row number for it. If there are multiple filesNLMultiple files are numbered together and output to the standard output.

 

Option

-B specifies the row number in two ways:

-B A indicates that the row number (similar to cat-N) is also listed no matter whether the row is empty or not)

-B T if there are blank rows, do not list the row numbers in the blank row (default)

-N: There are three methods for listing row numbers:

-N ln row number displayed on the far left of the screen

-The N rn row number is displayed on the rightmost side of its own column without adding 0

-N nz row number is displayed on the rightmost side of its own column, and 0 is added

-W: set the number of digits occupied by the row number column.

Example NL or NL-B t
$NLDemo1All people who can make an appointment2Enough food to eat3It's harder to talk and laugh than to cry.4How to get a hacker $NL-B t demo1All people who can make an appointment2Enough food to eat3It's harder to talk and laugh than to cry.4How can this problem be solved?

The row number is added by default, and the blank row is skipped.

 

NL-B
 
$NL-B A demo1All people who can make an appointment2Enough food to eat34It's harder to talk and laugh than to cry.5How can this problem be solved?

The row number is listed whether empty or not.

 

NL-N Rz
$NL-N rz demo000001All people who can make an appointment000002Enough food to eat000003It's harder to talk and laugh than to cry.000004How can this problem be solved?

List the row numbers and add 0 to them.

 

NL-n rz-W
$NL-N rz-W 3Demo001All people who can make an appointment002Enough food to eat003It's harder to talk and laugh than to cry.004How can this problem be solved?

Display the column of the row number

 

Tips

The NL command is similar to cat-B | cat-N, but NL is more flexible.

 

 

 

 

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.