In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to use the nl command in Linux. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
Linux common command nl command can automatically add the line number of the output file content! The default result is a little different from cat-n. Nl can do more display designs for line numbers, including the number of digits and whether or not to automatically complete 0, and so on.
Nl adds a line number to each file.
Summary nl [OPTION]... [FILE]... The main purpose is to add a line number to each input file and send it to standard output.
Read standard input when there is no file or when the file is-
Process logical pages (logical page).
The option-b,-- body-numbering=STYLE uses STYLE to append line numbers to the lines in the body section. -d,-- section-delimiter=CC uses CC as the logical page delimiter. -f,-- footer-numbering=STYLE uses STYLE to append line numbers to lines in the footer section. -h,-- header-numbering=STYLE uses STYLE to append line numbers to lines in the header section. -I,-- line-increment=NUMBER line number increment interval is NUMBER. -l,-- join-blank-lines=NUMBER the blank lines of consecutive NUMBER lines are treated as one line. -n,-- number-format=FORMAT inserts the line number according to FORMAT. -p,-- no-renumber do not reset the line number in each part. -s,-- number-separator=STRING adds the string STRING after the line number. -v,-- the starting line number of each part of the starting-line-number=NUMBER. -w,-- number-width=NUMBER line number width is NUMBER. -- help displays help information and exits. -- version displays version information and exits. The default option is:-bt-d'\:'- fn-hn-i1-L1-nrn-sTAB-V1-W6 CC is made up of two characters, defaults to\:, and if the second character is missing, it defaults to: STYLE can be one of the following available values: an all lines mark the line number. T is only a non-blank line mark line number. N does not mark the line number. The line number marked by the pBRE conforms to the underlying regular expression (BRE). FORMAT can be one of the following available values: ln is left-aligned and does not add a 0 at the beginning to meet the width. The rn is right-aligned and does not add a 0 at the beginning to meet the width. Rz aligns to the right, adding 0 at the beginning to meet the width. Logical page consists of three parts (header, body, footer) starting tag (header\:, body\::, footer\:) parameter FILE (optional): the file to be processed can be one or more.
A return value of 0 indicates success, while a non-zero value indicates failure.
Example nl_logicalpage.txt: this file is used to illustrate the nl command processing logic page The contents are as follows:\: header_1\: body_1\: footer_1\: header_2\:\: body_2\: footer_2 [user2@pc ~] $nl nl_logicalpage.txt header_1 1 body_1 footer_1 header_2 1 body_2 footer_2 [user2@pc ~] $nl-v0-fa-ha nl_ Logicalpage.txt 0 header_1 1 body_1 2 footer_1 0 header_2 1 body_2 2 footer_2 [user2@pc ~] $nl-p-fa-ha nl_logicalpage.txt 1 header_1 2 body_1 3 footer_1 4 header_2 5 body_2 6 footer_2 nl_normal.txt: this file is used to explain that the nl command processes ordinary files The contents are as follows: ZhuangZhu-74 2019-11-21 127.0.0.1 [user2@pc ~] $nl nl_normal.txt 1 ZhuangZhu-74 2 2019-11-21 3 127.0.0.1 [user2@pc ~] $nl-b packs 1 $'nl_normal.txt ZhuangZhu-74 1 2019-11-21 2 127.0.0.1 [user2@pc ~] $nl-b p' ^ [Amurz] 'nl_normal.txt 1 ZhuangZhu-74 2019-11-21 127.0.0.1 Note this command is a command in the GNU coreutils package For help, please see man-s 1 nl,info coreutils'nl invocation'.
This is the end of the article on "how to use nl commands in Linux". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.