[BACK]Return to csplit.1 CVS log [TXT][DIR] Up to [local] / src / usr.bin / csplit

Annotation of src/usr.bin/csplit/csplit.1, Revision 1.12

1.12    ! zhuk        1: .\"    $OpenBSD: csplit.1,v 1.11 2014/02/04 13:26:36 jmc Exp $
1.1       millert     2: .\"
                      3: .\" Copyright (c) 2002 Tim J. Robbins.
                      4: .\" All rights reserved.
                      5: .\"
                      6: .\" Redistribution and use in source and binary forms, with or without
                      7: .\" modification, are permitted provided that the following conditions
                      8: .\" are met:
                      9: .\" 1. Redistributions of source code must retain the above copyright
                     10: .\"    notice, this list of conditions and the following disclaimer.
                     11: .\" 2. Redistributions in binary form must reproduce the above copyright
                     12: .\"    notice, this list of conditions and the following disclaimer in the
                     13: .\"    documentation and/or other materials provided with the distribution.
                     14: .\"
                     15: .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
                     16: .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     17: .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     18: .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
                     19: .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     20: .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     21: .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     22: .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     23: .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     24: .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     25: .\" SUCH DAMAGE.
                     26: .\"
                     27: .\" $FreeBSD: src/usr.bin/csplit/csplit.1,v 1.11 2005/01/25 22:29:51 tjr Exp $
                     28: .\"
1.12    ! zhuk       29: .Dd $Mdocdate: February 4 2014 $
1.1       millert    30: .Dt CSPLIT 1
                     31: .Os
                     32: .Sh NAME
                     33: .Nm csplit
                     34: .Nd split files based on context
                     35: .Sh SYNOPSIS
                     36: .Nm
                     37: .Op Fl ks
                     38: .Op Fl f Ar prefix
                     39: .Op Fl n Ar number
                     40: .Ar file args ...
                     41: .Sh DESCRIPTION
                     42: The
                     43: .Nm
                     44: utility splits
                     45: .Ar file
                     46: into pieces using the patterns
                     47: .Ar args .
                     48: If
                     49: .Ar file
                     50: is
                     51: a dash
                     52: .Pq Sq - ,
                     53: .Nm
                     54: reads from standard input.
                     55: .Pp
1.5       jmc        56: Files are created with a prefix of
                     57: .Dq xx
                     58: and two decimal digits.
                     59: The size of each file is written to standard output
                     60: as it is created.
                     61: If an error occurs whilst files are being created,
                     62: or a
                     63: .Dv HUP ,
                     64: .Dv INT ,
                     65: or
                     66: .Dv TERM
                     67: signal is received,
                     68: all files previously written are removed.
                     69: .Pp
1.1       millert    70: The options are as follows:
                     71: .Bl -tag -width indent
                     72: .It Fl f Ar prefix
1.5       jmc        73: Create file names beginning with
                     74: .Ar prefix ,
                     75: instead of
1.1       millert    76: .Dq xx .
                     77: .It Fl k
1.5       jmc        78: Do not remove previously created files if an error occurs or a
1.1       millert    79: .Dv HUP ,
                     80: .Dv INT ,
                     81: or
                     82: .Dv TERM
                     83: signal is received.
                     84: .It Fl n Ar number
1.5       jmc        85: Create file names beginning with
1.1       millert    86: .Ar number
1.5       jmc        87: of decimal digits after the prefix,
                     88: instead of 2.
1.1       millert    89: .It Fl s
                     90: Do not write the size of each output file to standard output as it is
                     91: created.
                     92: .El
                     93: .Pp
                     94: The
                     95: .Ar args
                     96: operands may be a combination of the following patterns:
                     97: .Bl -tag -width indent
                     98: .It Xo
                     99: .Sm off
                    100: .No / Ar regexp No /
                    101: .Op Oo Cm + | - Oc Ar offset
                    102: .Sm on
                    103: .Xc
                    104: Create a file containing the input from the current line to (but not including)
                    105: the next line matching the given basic regular expression.
                    106: An optional
                    107: .Ar offset
                    108: from the line that matched may be specified.
                    109: .It Xo
                    110: .Sm off
                    111: .No % Ar regexp No %
                    112: .Op Oo Cm + | - Oc Ar offset
                    113: .Sm on
                    114: .Xc
                    115: Same as above but a file is not created for the output.
                    116: .It Ar line_no
                    117: Create containing the input from the current line to (but not including)
                    118: the specified line number.
                    119: .It { Ns Ar num Ns }
                    120: Repeat the previous pattern the specified number of times.
                    121: If it follows a line number pattern, a new file will be created for each
                    122: .Ar line_no
                    123: lines,
                    124: .Ar num
                    125: times.
                    126: The first line of the file is line number 1 for historic reasons.
                    127: .El
                    128: .Pp
                    129: After all the patterns have been processed, the remaining input data
                    130: (if there is any) will be written to a new file.
                    131: .Pp
                    132: Requesting to split at a line before the current line number or past the
                    133: end of the file will result in an error.
1.10      jmc       134: .Sh EXIT STATUS
1.9       jmc       135: .Ex -std csplit
1.1       millert   136: .Sh EXAMPLES
                    137: Split the
                    138: .Xr mdoc 7
                    139: file
                    140: .Pa foo.1
1.12    ! zhuk      141: into one file for each section (up to 21 files):
1.1       millert   142: .Pp
1.2       jmc       143: .Dl "$ csplit -k foo.1 '%^\e.Sh%' '/^\e.Sh/' '{20}'"
1.1       millert   144: .Pp
1.12    ! zhuk      145: Split standard input after the first 99 lines and every 100 lines
        !           146: thereafter (up to 21 files):
1.1       millert   147: .Pp
1.2       jmc       148: .Dl "$ csplit -k - 100 '{19}'"
1.1       millert   149: .Sh SEE ALSO
                    150: .Xr sed 1 ,
                    151: .Xr split 1 ,
                    152: .Xr re_format 7
                    153: .Sh STANDARDS
                    154: The
                    155: .Nm
1.3       jmc       156: utility is compliant with the
1.6       jmc       157: .St -p1003.1-2008
1.3       jmc       158: specification.
1.1       millert   159: .Sh HISTORY
                    160: A
                    161: .Nm
1.7       sobrado   162: command appeared in PWB
                    163: .Ux .
1.1       millert   164: .Sh BUGS
                    165: Input lines are limited to
                    166: .Dv LINE_MAX
                    167: (2048) bytes in length.