CSPLIT(1)

NAME
csplit - Split a file into sections determined by context lines

SYNOPSIS
csplit [-b|--suffix-format] [-f|--prefix] [-k|--keep-files] [--suppress-matched] [-n|--digits] [-q|--quiet] [-z|--elide-empty-files] [-h|--help] [-V|--version] <file> <pattern>

DESCRIPTION
Split a file into sections determined by context lines

OPTIONS

-b, --suffix-format <FORMAT>
    use sprintf FORMAT instead of %02d

-f, --prefix <PREFIX>
    use PREFIX instead of 'xx'

-k, --keep-files
    do not remove output files on errors

--suppress-matched
    suppress the lines matching PATTERN

-n, --digits <DIGITS>
    use specified number of digits instead of 2

-q, --quiet
    do not print counts of output file sizes

-z, --elide-empty-files
    remove empty output files

-h, --help
    Print help

-V, --version
    Print version

EXTRA
Output pieces of FILE separated by PATTERN(s) to files 'xx00', 'xx01', ..., and output byte counts of each piece to standard output.

VERSION
v(uutils coreutils) 0.10.0

EXAMPLES
Split a file in two parts, starting the second one at line 10:

csplit path/to/file 10

Split a file in three parts, starting the latter parts in lines 7 and 23:

csplit path/to/file 7 23

Start a new part at every 5th line (will fail if number of lines is not divisible by 5):

csplit path/to/file 5 {*}

Start a new part at every 5th line, ignoring exact-division error:

csplit [-k|--keep-files] path/to/file 5 {*}

Split a file above line 5 and use a custom prefix for the output files (default is `xx`):

csplit path/to/file 5 [-f|--prefix] prefix

Split a file above the first line matching a `regex` pattern:

csplit path/to/file /regex/

The examples are provided by the tldr-pages project <https://tldr.sh> under the CC BY 4.0 License. Please note that, as uutils is a work in progress, some examples might fail.