home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


UNIX in a Nutshell: System V Edition

UNIX in a Nutshell: System V EditionSearch this book
Previous: Reference: csh Chapter 2
UNIX Commands
Next: Reference: ctags
 

csplit



csplit

 [

options

] 

file

 

arguments

Separate file into sections and place sections in files named xx00 through xx n ( n < 100), breaking file at each pattern specified in arguments . See also split .

Options

-f file

Name new files file 00 through filen (default is xx00 through xx n ).

-k

Keep newly created files, even when an error occurs (which would normally remove these files). This is useful when you need to specify an arbitrarily large repeat argument, { n } , and you don't want the "out of range" error to remove the new files.

-s

Suppress all character counts.

Arguments

Any one or a combination of the following expressions. Arguments containing blanks or other special characters should be surrounded by single quotes.

/ expr/

Create file from the current line up to the line containing the regular expression expr . This argument takes an optional suffix of the form + n or - n , where n is the number of lines below or above expr .

% expr%

Same as / expr/ except no file is created for lines previous to line containing expr .

num

Create file from current line up to line number num .

{ n }

Repeat argument n times. May follow any of the above arguments. Files will split at instances of expr or in blocks of num lines.

Examples

Create up to 20 chapter files from the file novel :



csplit -k -f chap. novel '%CHAPTER%' '{20}'

Create up to 100 address files ( xx00 through xx99 ), each four lines long, from a database named address_list :



csplit -k address_list 4 {99}


Previous: Reference: csh UNIX in a Nutshell: System V Edition Next: Reference: ctags
Reference: csh Book Index Reference: ctags

The UNIX CD Bookshelf Navigation The UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System