csplit
v(uutils coreutils) 0.1.0
Options
--suffix-format=<FORMAT>
,-b <FORMAT>
-
csplit-help-suffix-format
--prefix=<PREFIX>
,-f <PREFIX>
-
csplit-help-prefix
--keep-files
,-k
-
csplit-help-keep-files
--suppress-matched
-
csplit-help-suppress-matched
--digits=<DIGITS>
,-n <DIGITS>
-
csplit-help-digits
--quiet
,--silent
,-q
,-s
-
csplit-help-quiet
--elide-empty-files
,-z
-
csplit-help-elide-empty-files
Examples
Split a file at lines 5 and 23:
csplit {{path/to/file}} 5 23
Split a file every 5 lines (this will fail if the total number of lines is not divisible by 5):
csplit {{path/to/file}} 5 {*}
Split a file every 5 lines, ignoring exact-division error:
csplit {{[-k|--keep-files]}} {{path/to/file}} 5 {*}
Split a file at line 5 and use a custom prefix for the output files:
csplit {{path/to/file}} 5 {{[-f|--prefix]}} {{prefix}}
Split a file at a line matching a regex
:
csplit {{path/to/file}} /{{regex}}/
The examples are provided by the tldr-pages project under the CC BY 4.0 License.
Please note that, as uutils is a work in progress, some examples might fail.