The csplit
command splits the FILE
file, separated with the PATTERN
, and outputs the results to files xx00
, xx01
, and so on. It also outputs the byte counts of each file to the standard output.
-b, --suffix-format=FORMAT
: Use the sprintf FORMAT
format instead of %02d
.-f, --prefix=PREFIX
: Use PREFIX
as a substitute for xx
.-k, --keep-files
: Do not delete the output files in case of errors.-m, --suppress-matched
: Suppress the lines matching PATTERN
.-n, --digits=DIGITS
: Use the specified number of digits instead of 2
.-s, --quiet, --silent
: Do not print the count of output file sizes.-z, --elide-empty-files
: Remove empty output files.--help
: Output help information.--version
: Output version information.If the file is specified as a hyphen -
, csplit
will read from the standard input. Each pattern can be:
INTEGER
: Copy up to the specified line number, but not including the specified line number./REGEXP/[OFFSET]
: Copy up to but not including the matching line.%REGEXP%[OFFSET]
: Skip to but not including the matching line.{INTEGER}
: Repeat the specified number of times of the previous pattern.{*}
: Repeat the previous pattern as many times as possible.The file list.txt
contains the following content:
Using the csplit
command to split this file into two parts, with the second part starting from the third line.
Using the csplit
command to split this file into three parts.
Using a custom split prefix aa
instead of the default xx
split prefix.
Using three digits instead of the default two digits.
Using a pattern to define the split rule and repeat the specified number of times of the previous pattern.