1. Tutorial
Write each FILE to standard output, with line numbers added.
2. Usage
nl [OPTION]... [FILE]...
2.1 重要常用参数
-b, —body-numbering=STYLE use STYLE for numbering body lines
-n, —number-format=FORMAT insert line numbers according to FORMAT
-w, —number-width=NUMBER use NUMBER columns for line numbers
-s, —number-separator=STRING add STRING after (possible) line number
-v, —starting-line-number=NUMBER first line number for each section
—help display this help and exit
—version output version information and exit
-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
STYLE**:
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**:**
ln left justified, no leading zeros
rn right justified, no leading zeros
rz right justified, leading zeros
3. UseCase
// abc.md
# Haha
## 1. xixi
## 2. haha
## 3. wow
## 4. aef
## 5. faefao
仅对非空行增加行号,行号靠右占3起始位10,跟随 ;
nl -bt -nrn -s";" -v10 -w3 abc.md
10;# Haha
11;## 1. xixi
12;## 2. haha
13;## 3. wow
14;## 4. aef
15;## 5. faefao
仅对非空行增加行号,行号靠右占2位起始97,跟随 \
nl -bt -nrn -v97 -w2 -s"\\" abc.md
97\# Haha
98\## 1. xixi
99\## 2. haha
100\## 3. wow
101\## 4. aef
102\## 5. faefao