{{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 and Unix-like | platform = Cross-platform | genre = Command | license = GNU GPL v3 | website = }} '''<code>csplit</code>''' is a shell command for splitting a file into two or more smaller files determined by context lines. The command is commonly available on Unix and Unix-like operating systems.

The command 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.<ref>{{man|cu|csplit|SUS}}</ref> It first appeared in PWB UNIX.<ref>{{man|1|csplit|FreeBSD}}</ref> The version in GNU 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 via 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 arguments consist of options, a file path and a list of patterns.

Each patterns is a line number or 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 bytes, to standard output.

==Comparison to split== The <code>split</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