csplit(1)

csplit(1)

NAME

csplit - context split

SYNOPSIS

csplit [-s][-k][-fpre®x ] [-nnumber] ®le arg1 [ ... argn ]

DESCRIPTION

csplit reads ®le, separates it into n+1 sections as de®ned by the arguments arg1 ... argn, and places the results in separate ®les. The maximum number of arguments (arg1 through argn) allowed is 99 unless the -nnumber option is used to allow for more output ®le names. If the -fpre®x option is speci®ed, the resulting ®lenames are pre®x00 through pre®x NN where NN is the two-digit value of n using a leading zero if n is less than 10. If the -fpre®x option is not speci®ed, the default ®lenames xx00 through xxNN are used. ®le is divided as follows:

Default

Pre®xed

 

 

Filename

Filename

Contents

xx00

pre®x00

From start of ®le up to (but not including) the line refer-

 

 

 

enced by arg1.

xx01

pre®x01

From the line referenced by arg1 up to the line referenced

 

 

by arg2.

 

 

.

 

 

 

.

 

 

 

.

 

xxNN

pre®xNN

From the line referenced by argn to end of ®le.

If the ®le argument is -, standard input is used.

csplit supports the Basic Regular Expression syntax (see regexp(5)).

Options

csplit recognizes the following options:

-s

Suppress printing of all character counts (csplit normally prints the character

 

counts for each ®le created).

-k

Leave previously created ®les intact (csplit normally removes created ®les if an

 

error occurs).

-fprefix

Name created ®les pre®x00 through pre®xNN (default is xx00 through xxNN.

-nnumber

The output ®le name suf®x will use number digits instead of the default 2. This

 

allows creation of more than 100 output ®les.

Arguments (arg1 through argn) to csplit can be any combination of the following:

/regexp/ Create a ®le containing the section from the current line up to (but not including) the line matching the regular expression regexp. The new current line becomes the line matching regexp.

/regexp/+n

/regexp/-nCreate a ®le containing the section from the current line up to (but not including) the nth before (-n) or after (+n) the line matching the regular expression regexp. (e.g., /Page/-5). The new current line becomes the line matching regexp±n lines.

%regexp% equivalent to /regexp/, except that no ®le is created for the section.

line_number Create a ®le from the current line up to (but not including) line_number. The new current line becomes line_number.

{num} Repeat argument. This argument can follow any of the above argument forms. If it follows a regexp argument, that argument is applied num more times. If it follows line_number, the ®le is split every line_number lines for num times from that point until end-of-®le is reached or num expires.

{*}

Repeats previous operand as many times as necessary to ®nish input.

Enclose in appropriate quotes all regexp arguments containing blanks or other characters meaningful to the shell. Regular expressions must not contain embedded new-lines. csplit does not alter or remove the

HP-UX Release 11i: December 2000

− 1 −

Section 1147

c