csplit(context split)
csplit(context split)功能说明:分割文件。
语 法:csplit [-kqsz][-b<输出格式>][-f<输出字首字符串>][-n<输出文件名位数>][--help][--version][文件][范本样式...]
补充说明:将文件依照指定的范本样式予以切割后,分别保存成名称为xx00,xx01,xx02...的文件。若给予的文件名称为"-",则csplit指令会从标准输入设备读取数据。
参 数:
-b<输出格式>或--suffix-format=<输出格式> 预设的输出格式其文件名称为xx00,xx01...等,您可以通过改变<输出格式>来改变输出的文件名。
-f<输出字首字符串>或--prefix=<输出字首字符串> 预设的输出字首字符串其文件名为xx00,xx01...等,如果你指定输出字首字符串为"hello",则输出的文件名称会变成hello00,hello01...等。
-k或--keep-files 保留文件,就算发生错误或中断执行,也不能删除已经输出保存的文件。
-n<输出文件名位数>或--digits=<输出文件名位数> 预设的输出文件名位数其文件名称为xx00,xx01...等,如果你指定输出文件名位数为"3",则输出的文件名称会变成xx000,xx001...等。
-q或-s或--quiet或--silent 不显示指令执行过程。
-z或--elide-empty-files 删除长度为0 Byte文件。
--help 在线帮助。
--version 显示版本信息。
csplit
csplit [options] file arguments
Separate file into context-based sections and place sections in files named xx00 through xxn (n < 100), breaking file at each pattern specified in arguments. See also split.
Options
Read from standard input.
Append suffix to output filename. This option causes -n to be ignored. suffix must specify how to convert the binary integer to readable form by including one of the following: %d, %i, %u, %o, %x, or %X. The value of suffix determines the format for numbers as follows:
%d Signed decimal.
%i Same as %d.
%u Unsigned decimal.
%o Octal.
%x Hexadecimal.
%X Same as %x.
Name new files prefix00 through prefixn (default is xx00 through xxn).
Keep newly created files even when an error occurs (which would normally remove these files). This is useful when you need to specify an arbitrarily large repeat argument, {n}, and you don't want an out-of-range error to cause removal of the new files.
Use output filenames with numbers num digits long. The default is 2.
Suppress all character counts.
Do not create empty output files. However, number as if those files had been created.
Arguments
Any one or a combination of the following expressions may be specified as arguments. Arguments containing blanks or other special characters should be surrounded by single quotes.
Create file from the current line up to the line containing the regular expression expr. offset should be of the form +n or -n, where n is the number of lines below or above expr.
Same as /expr/, except no file is created for lines previous to line containing expr.
Create file from current line up to (but not including) line number num. When followed by a repeat count (number inside { }), put the next num lines of input into another output file.
Repeat argument n times. May follow any of the preceding arguments. Files will split at instances of expr or in blocks of num lines. If * is given instead of n, repeat argument until input is exhausted.
Examples
Create up to 20 chapter files from the file novel:
csplit -k -f chap. novel '/CHAPTER/' '{20}'
Create up to 100 address files (xx00 through xx99), each four lines long, from a database named address_list:
csplit -k address_list 4 {99}