Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ csplit(1) — AIX PS/2 1.2.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

ed, red

sh, Rsh

regcmp

regxp



CSPLIT(1,C)                 AIX Commands Reference                  CSPLIT(1,C)



-------------------------------------------------------------------------------
csplit



PURPOSE

Splits files by context.

SYNTAX


          +---------------+
csplit ---| +-----------+ |-- file -- parm --|
          +-| -f prefix |-+         ^      |
           ^| -k        ||          +------+
           || -s        ||
           |+-----------+|
           +-------------+


Note:  This command does not have MBCS support.

DESCRIPTION

The csplit command reads a file and separates it into segments defined by the
specified parameters (parm...).  By default, the csplit command writes these
segments to files xx00...xxn, where n is the number of parameters (parm) listed
on the command line (n may not be greater than 99).  These new files get the
following pieces of file:

00:    From the start of file up to, but not including, the line referenced by
       the first parm.
01:    From the line referenced by the first parm up to the line referenced by
       the second parm.
       .
       .
       .
n+1:   From the line referenced by the last parm to the end of file.

The csplit command does not alter the original file.

The specified parms can be a combination of the following:

/pattern/     Creates a file that contains the segment from the current line up
              to (but not including) the line containing pattern, which becomes
              the current line.

%pattern%     Makes the line containing pattern the current line but does not
              create a file for the segment.





Processed November 8, 1990        CSPLIT(1,C)                                 1





CSPLIT(1,C)                 AIX Commands Reference                  CSPLIT(1,C)



+num

-num          Moves forward or backward the specified number of lines from the
              line matched by an immediately preceding pattern parameter (for
              example, "/Page/-5").

linenum       Creates a file containing the segment from the current line up to
              (but not including) linenum, which becomes the current line.

{number}      Repeats the preceding argument the specified number of times.
              This number can follow any of the pattern or linenum parameters.
              If it follows a pattern parameter, the csplit command reuses that
              pattern the specified number of times.  If it follows a linenum
              parameter, the csplit command splits the file from that point
              every linenum of lines for the specified number of times.

Quote all pattern parameters that contain blanks or other characters special to
the shell.  Patterns may not contain embedded new-line characters.  In an
expression such as [a-z], the minus means "through" according to the current
collating sequence.  A collating sequence may define equivalence classes for
use in character ranges.  See "Overview of International Character Support" in
Managing the AIX Operating System for more information on collating sequences
and equivalence classes.

FLAGS

-f  prefix   Specifies the prefix name for the created file segments.  xx is
             the default prefix.

-k           Leaves created file segments intact in the event of an error.

-s           Suppresses the display of character counts.

EXAMPLES

  1. To split the text of a book into a separate file for each chapter:

      csplit book "/^Chapter *[1-9]/" {8}

    This command creates files named xx00, xx01, xx02,...,xx09, which contain
    individual chapters of the file book.  Each chapter begins with a line that
    contains only the word "Chapter" and the chapter number.  The file xx00
    contains the front matter that comes before the first chapter.  The repeat
    argument "{8}" after the pattern allows up to nine chapters.

  2. To specify the prefix for the created file names:

      csplit -f chap book "/^Chapter *[1-9]/" {8}

    This command splits "book" into files named "chap"00, "chap"01,
    "chap"02,...,"chap"09.




Processed November 8, 1990        CSPLIT(1,C)                                 2





CSPLIT(1,C)                 AIX Commands Reference                  CSPLIT(1,C)



RELATED INFORMATION

See the following commands:  "ed, red,"  "sh, Rsh," and  "regcmp."

See the regxp file in AIX Operating System Technical Reference.

See "Overview of International Character Support" in Managing the AIX Operating
System.















































Processed November 8, 1990        CSPLIT(1,C)                                 3



Typewritten Software • bear@typewritten.org • Edmonds, WA 98026