-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathsplit.sh
More file actions
144 lines (72 loc) · 1.38 KB
/
split.sh
File metadata and controls
144 lines (72 loc) · 1.38 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
## Default split
seq 10000 | split
ls x*
head -n1 xaa xab xae xaj
rm x*
## Change number of lines
split -l3 purchases.txt
head x*
## Split by byte count
split -b15 greeting.txt
head x*
cat x*
split -C20 purchases.txt
head x*
wc -c x*
printf 'apple\nbanana\n' | split -C4
head x*
cat x*
## Divide based on file size
split -n2 purchases.txt
head x*
wc x*
seq 6 | split -n2
split -n1/2 greeting.txt
split -nl/2 purchases.txt
head x*
split -nl/2/3 sample.txt
## Interleaved lines
seq 5 | split -nr/2
head x*
split -nr/1/3 sample.txt
## Custom line separator
printf 'apple\nbanana\n;mango\npapaya\n' | split -t';' -l1
head x*
## Customize filenames
split -l1 greeting.txt op_
head op_*
seq 10 | split -l1 -a1
ls x*
rm x*
seq 10 | split -l1 -a3
ls x*
rm x*
seq 100 | split -l1 -a1
ls x*
rm x*
seq 10 | split -l1 -d
ls x*
rm x*
seq 10 | split -l2 --numeric-suffixes=10
ls x*
seq 10 | split -l1 --hex-suffixes=8
ls x*
seq 10 | split -l2 -a1 --additional-suffix='.log'
ls x*
rm x*
seq 10 | split -l2 -a1 -d --additional-suffix='.txt' - num_
ls num_*
## Exclude empty files
split -nl/3 greeting.txt
head x*
rm x*
split -e -nl/3 greeting.txt
head x*
## Process parts through another command
split -l1 --filter='gzip > $FILE.gz' greeting.txt
ls x*
zcat xaa.gz
zcat xab.gz
cat body_sep.txt
split -l3 --filter='tail -n +2 > $FILE' body_sep.txt
head x*