Linux Comm Csplit
# Linux csplit Command
[ Linux Command Manual](#)
The Linux csplit command is used to split files.
It splits a file according to specified pattern templates and saves the parts into files named xx00, xx01, xx02, etc. If the given filename is "-", the csplit command reads data from the standard input device.
### Syntax
csplit [pattern template...]
**Parameters**:
* -b or --suffix-format= The default output format for filenames is xx00, xx01, etc. You can change the output filenames by altering the .
* -f or --prefix= The default output prefix string for filenames is xx00, xx01, etc. If you specify the output prefix string as "hello", the output filenames will become hello00, hello01, etc.
* -k or --keep-files Keep files. Even if an error occurs or execution is interrupted, do not delete the already output and saved files.
* -n or --digits= The default number of digits for output filenames is xx00, xx01, etc. If you specify the output filename digits as "3", the output filenames will become xx000, xx001, etc.
* -q or -s or --quiet or --silent Do not display the command execution process.
* -z or --elide-empty-files Delete files with a length of 0 bytes.
* --help Online help.
* --version Display version information.
### Example
Split the text file `testfile` into two parts at the 2nd line, using the following command:
csplit testfile 2
The content of the `testfile` file is as follows:
$ cat testfile #View the content of testfile file
hello Linux!
Linux is a free Unix-type operating system.
This is a Linux testfile!
Linux
Using the `csplit` command, the output is as follows:
$ csplit testfile 2
76 #xx00 file character count
13 #xx01 file character count
The first line is the character count of the first file `xx00`, and similarly, the second line is the character count of the second file `xx01`. At the same time, two files will be generated in the same directory as `testfile`, named `xx00` and `xx01`. The content of `xx00` is:
$ cat xx00 #View the content of the split xx00 file
hello Linux! #Content of the 1st line of the testfile file
The content of `xx01` is:
$ cat xx01 #View the content of the split xx01 file
Linux is a free Unix-type operating system. #Content from the 2nd line onwards of the testfile file
This is a Linux testfile!
Linux
[ Linux Command Manual](#)
YouTip