csplit – split a file into sections determined by context lines

A UNIX Command

$cat test.text
hello
how
are you ?
$csplit test.text 1
0
20
$cat xx00
$cat xx01
hello
how
are you ?
$rm xx*
$csplit test.text 2
6
14
$cat xx00
hello
$cat xx01
how
are you ?
$rm xx*
$csplit test.text 3
10
10
$cat xx01
are you ?
$cat xx00
hello
how
$csplit test.text 4
20
csplit: `4': line number out of range
$cat xx01
are you ?
$ls xx00
ls: cannot access xx00: No such file or directory
$


UNIX Explanation

Output pieces  of FILE  separated by PATTERN(s)  to files
`xx00', `xx01', ..., and output byte counts of each piece
to standard output.

 

Leave a Reply

Your email address will not be published. Required fields are marked *