English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The Linux csplit command is used to split files.
After cutting the file according to the specified template style, save it separately with the name of xx00,xx01,xx02...file. If the given file name is"-If a comma is used, the csplit command will read data from the standard input device.
csplit [-kqsz][-b<output format>][-f<output file name prefix>] [-n<output file name length>][--help][--version][file][template style...]
Parameter:
-b<output format> or--suffix-format=<output format> The default output format is its file name as xx00,xx01...et al., you can change the output file name by changing the <output format>.
-f<output file name prefix> or--prefix=<output file name prefix> The default output file name prefix is its file name as xx00,xx01...et al., if you specify the output file name prefix as "hello", then the output file name will become hello00,hello01...et al.
-k or--keep-files Keep the file, even if an error occurs or the execution is interrupted, the output file that has been saved cannot be deleted.
-n<output file name length> or--digits=<output file name length> The default output file name length is its file name as xx00,xx01...et al., if you specify the output file name length as "3If a comma is used, the output file name will become xx000,xx001...et al.
-q or-s or--quiet or--silent Do not display the execution process of the instruction.
-z or--elide-empty-files Delete files with a length of 0 Byte.
--help Online help.
--version Show version information.
Split the text file testfile at the 2 Line is split into two parts, using the following command:
csplit testfile 2
The content of testfile is as follows:
$ cat testfile #View the content of testfile 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 13 #xx00 file character count 76 #xx01File character count
Among which the1 Line is the number of characters in the first file xx00, similarly, the2 Line is the second file xx01The number of characters. At the same time, two files will be generated in the same directory as testfile, named xx00 and xx01, the content of xx00 is as follows:
$ cat xx00 #View the content of the split xx00 file hello Linux! #testfile file line1line content
xx01 The content is as follows:
$ cat xx01 #View the split xx01File content Linux is a free Unix-type operating system. #testfile file line2Content after this line This is a Linux testfile! Linux