# Csplit

> Mediated Wiki article. Canonical URL: https://mediated.wiki/source/Csplit
> Markdown URL: https://mediated.wiki/source/Csplit.md
> Source: https://en.wikipedia.org/wiki/Csplit
> Source revision: 1336332037
> License: Creative Commons Attribution-ShareAlike 4.0 International (https://creativecommons.org/licenses/by-sa/4.0/)

{{Short description |Shell command for splitting files}}
{{lowercase}}
{{Infobox software
| name                   = csplit
| logo                   = 
| screenshot             = 
| screenshot size        = 
| caption                = 
| author                 = 
| developer              = 
| released               = 
| latest release version = 
| latest release date    = 
| operating system       = [Unix](/source/Unix) and [Unix-like](/source/Unix-like)
| platform               = [Cross-platform](/source/Cross-platform)
| genre                  = [Command](/source/Command_(computing))
| license                = [GNU GPL v3](/source/GNU_General_Public_License)
| website                = 
}}
'''<code>csplit</code>''' is a [shell](/source/shell_(computing)) [command](/source/command_(computing)) for splitting a [file](/source/Computer_file) into two or more smaller files determined by context lines. The command is commonly available on [Unix](/source/Unix) and [Unix-like](/source/Unix-like) [operating system](/source/operating_system)s.

The command is part of the [X/Open](/source/X%2FOpen) Portability Guide since issue 2 of 1987. It was inherited into the first version of POSIX and the [Single Unix Specification](/source/Single_Unix_Specification).<ref>{{man|cu|csplit|SUS}}</ref> It first appeared in PWB UNIX.<ref>{{man|1|csplit|FreeBSD}}</ref> The version in [GNU](/source/GNU) [coreutils](/source/coreutils) was written by Stuart Kemp and David MacKenzie.<ref>{{Cite web|url=https://linux.die.net/man/1/csplit|title=Csplit(1) - Linux man page|access-date=2019-01-26|archive-date=2019-07-31|archive-url=https://web.archive.org/web/20190731104010/https://linux.die.net/man/1/csplit|url-status=live}}</ref> The command is available for [Windows](/source/Windows) via [UnxUtils](/source/UnxUtils).<ref>{{Cite web|url=https://unxutils.sourceforge.net/|title=Native Win32 ports of some GNU utilities|website=unxutils.sourceforge.net|access-date=2025-08-09|archive-date=2006-02-09|archive-url=https://web.archive.org/web/20060209022842/http://unxutils.sourceforge.net/|url-status=live}}</ref>

==Usage==
The [command line](/source/command_line) arguments consist of options, a file path and a list of patterns.

Each patterns is a [line number](/source/line_number) or [regular expression](/source/regular_expression). The program outputs pieces of the file separated by the patterns into files <code>xx00</code>, <code>xx01</code>, etc., and outputs the size of each piece, in [byte](/source/byte)s, to [standard output](/source/standard_output).

==Comparison to split==
The <code>[split](/source/split_(Unix))</code> command also splits a file into pieces, although the pieces are of a fixed size, measured in lines or bytes.

==See also==
* {{Annotated link |List of POSIX commands}}

==References==
{{Reflist}}

==Further reading==
* 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==
{{Wikibooks|Guide to Unix|Commands}}
*{{man|cu|csplit|SUS|split files based on context}}

{{Unix commands}}
{{Core Utilities commands}}

Category:Standard Unix programs
Category:Unix SUS2008 utilities

---
Adapted from the Wikipedia article [Csplit](https://en.wikipedia.org/wiki/Csplit) by Wikipedia contributors ([contributor history](https://en.wikipedia.org/wiki/Csplit?action=history)). Available under [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). Changes may have been made.
