csplit

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search
csplit
Operating systemUnix and Unix-like
PlatformCross-platform
TypeCommand
LicenseGNU GPL v3

The csplit command in Unix and Unix-like operating systems is a utility that is used to split a file into two or more smaller files determined by context lines.

History[edit]

csplit is part of the X/Open Portability Guide since issue 2 of 1987. It was inherited into the first version of POSIX and the Single Unix Specification.[1] It first appeared in PWB UNIX.[2]

The version of csplit bundled in GNU coreutils was written by Stuart Kemp and David MacKenzie.[3]

Usage[edit]

The command-syntax is:

csplit [OPTION]... FILE PATTERN...

The patterns may be line numbers or regular expressions. The program outputs pieces of the file separated by the patterns into files xx00, xx01, etc., and outputs the size of each piece, in bytes, to standard output.

The optional parameters modify the behaviour of the program in various ways. For example, the default prefix string (xx) and number of digits (2) in the output filenames can be changed.

As with most Unix utilities, a return code of 0 indicates success, while nonzero values indicate failure.

Comparison to split[edit]

The split command also splits a file into pieces, except that all the pieces are of a fixed size (measured in lines or bytes).

See also[edit]

References[edit]

  1. ^ csplit – Commands & Utilities Reference, The Single UNIX Specification, Issue 7 from The Open Group
  2. ^ csplit(1) – FreeBSD General Commands Manual
  3. ^ https://linux.die.net/man/1/csplit

Further reading[edit]

  • Ellen Siever, Aaron Weber, Stephen Figgins, Robert Love, Arnold Robbins, et al. Linux in a Nutshell, 5th Edition. O'Reilly Media: July 2005. ISBN 978-0-596-00930-4.

External links[edit]