Latest web development tutorials

Linux csplit command

Linux command Daquan Linux command Daquan

Linux csplit command is used to split files.

After specifying the file in accordance with the template styles to be cut, were preserved fame called xx00, xx01, xx02 ... files. If the file name is given as "-", then csplit instruction input device to read data from the standard.

grammar

csplit [-kqsz][-b<输出格式>][-f<输出字首字符串>]
[-n<输出文件名位数>][--help][--version][文件][范本样式...] 

Parameters:

  • -b <output format> or --suffix-format = <output format> preset output file format whose name is xx00, xx01 ... and so on, you can change the output file name by changing the <output format>.
  • -f <output prefix string> or --prefix = <output string prefix> default output file name prefix string whose xx00, xx01 ... and so on, if you specify the output string for the prefix "hello", the name of the output file will become hello00, hello01 ... and so on.
  • -k or --keep-files retain the file, even if an error or interrupt the execution, you can not delete saved files have been output.
  • -n <output filename digits> or --digits = <output filename digits> default output file name is the name of its file-digit xx00, xx01 ... and so on, if you specify the output file name median "3", the name of the output file will become xx000, xx001 ... and so on.
  • -s or -q or --quiet or --silent not displayed during the execution of instructions.
  • -z or --elide-empty-files remove a length of 0 Byte files.
  • --help online help.
  • --version display version information.

Examples

The text file testfile to conduct the second cut-off point cut in two, use the following command:

csplit testfile 2

testfile file reads as follows:

$ cat testfile #查看testfile 文件内容  
hello Linux!  
Linux is a free Unix-type operating system.  
This is a Linux testfile!  
Linux 

Use csplit command, the output results are as follows:

$ csplit testfile 2  
13 #xx00文件字符个数  
76 #xx01文件字符个数  

The first row is the first file xx00 number of characters, the same second behavior of the second file is the number of characters xx01. Meanwhile, in the same directory testfile will generate two files, the file names are xx00, xx01, xx00 contents as follows:

$ cat xx00 #查看分割后的xx00文件内容  
hello Linux! #testfile文件第1行的内容 

xx01 contents as follows:

$ cat xx01 #查看分割后的xx01文件内容  
Linux is a free Unix-type operating system. #testfile文件第2行以后的内容  
This is a Linux testfile!  
Linux 

Linux command Daquan Linux command Daquan