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

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s