nl 命令
命令简介
nl(Number of Lines)将指定的文件添加行号标注后写到标准输出。如果不指定文件或指定文件为"-" ,程序将从标准输入读取数据。
-b : 指定添加行号的方式,主要有两种:
-b a:表示无论是否为空行,同样列出行号("cat -n"就是这种方式)
-b t:只列出非空行的编号并列出(默认为这种方式)
-n : 设置行号的样式,主要有三种:
-n ln:在行号字段最左端显示
-n rn:在行号字段最右边显示,且不加0
-n rz:在行号字段最右边显示,且加0
-w : 行号字段占用的位数(默认为6位)
image.png
Usage: nl [OPTION]... [FILE]...
Write each FILE to standard output, with line numbers added.
With no FILE, or when FILE is -, read standard input.
Mandatory arguments to long options are mandatory for short options too.
-b, --body-numbering=STYLE use STYLE for numbering body lines 使用指定样式编号文件的正文行目
-d, --section-delimiter=CC use CC for separating logical pages 使用指定的CC 分割逻辑页数
-f, --footer-numbering=STYLE use STYLE for numbering footer lines 使用指定样式编号文件的页脚行目
-h, --header-numbering=STYLE use STYLE for numbering header lines 使用指定样式编号文件的页眉行目
-i, --line-increment=NUMBER line number increment at each line 设置每一行遍历后的自动递增值
-l, --join-blank-lines=NUMBER group of NUMBER empty lines counted as one 设置数值为多少的若干空行被视作一行
-n, --number-format=FORMAT insert line numbers according to FORMAT 根据指定格式插入行号
-p, --no-renumber do not reset line numbers at logical pages 在逻辑页数切换时不将行号值复位
-s, --number-separator=STRING add STRING after (possible) line number 可能的话在行号后添加字符串
-v, --starting-line-number=NUMBER first line number on each logical page
-w, --number-width=NUMBER use NUMBER columns for line numbers
--help display this help and exit
--version output version information and exit
By default, selects -v1 -i1 -l1 -sTAB -w6 -nrn -hn -bt -fn. CC are
two delimiter characters for separating logical pages, a missing
second character implies :. Type \\ for \. STYLE is one of:
a number all lines
t number only nonempty lines
n number no lines
pBRE number only lines that contain a match for the basic regular
expression, BRE
FORMAT is one of:
ln left justified, no leading zeros
rn right justified, no leading zeros
rz right justified, leading zeros
GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
For complete documentation, run: info coreutils 'nl invocation'
网友评论