介紹
nl
指令用來檢視檔案並加上行號。
語法
nl [options] [files]
常用的options
-b [a|t|n|p R] Prepend numbers to all lines (a), nonblank lines (t), no lines (n), or only lines that contain regular expression R. (Default=a)
-v N Begin numbering with integer N. (Default=1)
-i N Increment the number by N for each line, so for example, you could use odd numbers only (-i 2) or even numbers only (-v 2 -i 2). (Default=1)
-n [ln|rn|rz] Format numbers as left-justified (ln), right-justified (rn), or right-justified with leading zeros (rz). (Default=ln)
-w N Force the width of the number to be N columns. (Default=6)
-s S Insert string S between the line number and the text. (Default=Tab)
範例
你可以檢視檔案並加上行號:
⤍ cat mytext
Once upon a time, there was
a little operating system named
Linux, which everybody loved.
⤍ nl mytext
1 Once upon a time, there was
2 a little operating system named
3 Linux, which everybody loved.
發佈留言