-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathnl.sh
More file actions
68 lines (34 loc) · 1 KB
/
nl.sh
File metadata and controls
68 lines (34 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
## Default numbering
nl greeting.txt fruits.txt nums.txt
printf 'apple\n\nbanana\n\ncherry\n' | nl
## Number formatting
nl -n'rn' greeting.txt
nl -n'rz' greeting.txt
nl -n'ln' greeting.txt
## Customize width
nl greeting.txt
nl -w2 greeting.txt
## Customize separator
nl -w2 -s' ' greeting.txt
nl -w1 -s' --> ' greeting.txt
## Starting number and step value
nl -v10 greeting.txt
nl -v-1 fruits.txt
nl -w2 -s') ' -i2 greeting.txt fruits.txt nums.txt
nl -w1 -s'. ' -v8 -i-1 greeting.txt fruits.txt
## Section wise numbering
cat body.txt
nl -w1 -s' ' body.txt
cat header_body.txt
nl -w1 -s' ' header_body.txt
cat all_sections.txt
nl -w1 -s' ' all_sections.txt
nl -w1 -s' ' -ha -fa all_sections.txt
nl -p -w1 -s' ' all_sections.txt
nl -p -w1 -s' ' -ha -fa all_sections.txt
cat body_sep.txt
nl -w1 -s' ' -d'%=' body_sep.txt
## Section numbering criteria
printf 'apple\n\nbanana\n\ncherry\n' | nl -w1 -s' ' -ba
printf 'a\n\n\n\n\nb\n\nc' | nl -w1 -s' ' -ba -l2
nl -w1 -s' ' -bp'^[ct]' purchases.txt