i'am trying to use csplit command on a file of 700 Mo. I would like to split the file into 30 smallers files and also respect the tag name i use to start a new file.
<head>
<test>1 </test>
</head>
<head>
<test>2 </test>
</head>
<head>
<test>3 </test>
</head>
...
<head>
<test> 80 </test>
</head>
Suppose i have 80 groups tags so i would like to generate exactly 30 files. So how can i do it using csplit. The begining i know is
csplit output_prefix File '/<head>/' '{*}'
答案 0 :(得分:2)
发现csplit
只是成功的一半!这应该有效:
% csplit --prefix File --elide-empty-files foo.xml '/<head>/' '{*}'
33
33
...
% ls
File00 File01 File02 ... foo.xml
选项/参数顺序很重要。请尝试csplit --help
查看其所有选项。
% csplit --help
Usage: csplit [OPTION]... FILE PATTERN...