{
    "mode": "man",
    "parameter": "CSPLIT",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/CSPLIT/1/json",
    "generated": "2026-06-11T13:44:32Z",
    "synopsis": "csplit [OPTION]... FILE PATTERN...",
    "sections": {
        "NAME": {
            "content": "csplit - split a file into sections determined by context lines\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "csplit [OPTION]... FILE PATTERN...\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Output  pieces  of FILE separated by PATTERN(s) to files 'xx00', 'xx01', ..., and output byte\ncounts of each piece to standard output.\n\nRead standard input if FILE is -\n\nMandatory arguments to long options are mandatory for short options too.\n",
            "subsections": [
                {
                    "name": "-b --suffix-format",
                    "content": "use sprintf FORMAT instead of %02d\n",
                    "flag": "-b",
                    "long": "--suffix-format"
                },
                {
                    "name": "-f --prefix",
                    "content": "use PREFIX instead of 'xx'\n",
                    "flag": "-f",
                    "long": "--prefix"
                },
                {
                    "name": "-k --keep-files",
                    "content": "do not remove output files on errors\n",
                    "flag": "-k",
                    "long": "--keep-files"
                },
                {
                    "name": "--suppress-matched",
                    "content": "suppress the lines matching PATTERN\n",
                    "long": "--suppress-matched"
                },
                {
                    "name": "-n --digits",
                    "content": "use specified number of digits instead of 2\n",
                    "flag": "-n",
                    "long": "--digits"
                },
                {
                    "name": "-s --quiet --silent",
                    "content": "do not print counts of output file sizes\n",
                    "flag": "-s",
                    "long": "--silent"
                },
                {
                    "name": "-z --elide-empty-files",
                    "content": "remove empty output files\n\n--help display this help and exit\n",
                    "flag": "-z",
                    "long": "--elide-empty-files"
                },
                {
                    "name": "--version",
                    "content": "output version information and exit\n",
                    "long": "--version"
                },
                {
                    "name": "Each PATTERN may be:",
                    "content": "INTEGER\ncopy up to but not including specified line number\n\n/REGEXP/[OFFSET]\ncopy up to but not including a matching line\n\n%REGEXP%[OFFSET]\nskip to, but not including a matching line\n\n{INTEGER}\nrepeat the previous pattern specified number of times\n\n{*}    repeat the previous pattern as many times as possible\n\nA line OFFSET is a required '+' or '-' followed by a positive integer.\n"
                }
            ]
        },
        "AUTHOR": {
            "content": "Written by Stuart Kemp and David MacKenzie.\n",
            "subsections": []
        },
        "REPORTING BUGS": {
            "content": "GNU coreutils online help: <https://www.gnu.org/software/coreutils/>\nReport any translation bugs to <https://translationproject.org/team/>\n",
            "subsections": []
        },
        "COPYRIGHT": {
            "content": "Copyright © 2020 Free Software Foundation, Inc.  License GPLv3+: GNU GPL version 3  or  later\n<https://gnu.org/licenses/gpl.html>.\nThis  is free software: you are free to change and redistribute it.  There is NO WARRANTY, to\nthe extent permitted by law.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "Full documentation <https://www.gnu.org/software/coreutils/csplit>\nor available locally via: info '(coreutils) csplit invocation'\n\n\n\nGNU coreutils 8.32                          January 2026                                   CSPLIT(1)",
            "subsections": []
        }
    },
    "summary": "csplit - split a file into sections determined by context lines",
    "flags": [
        {
            "flag": "-b",
            "long": "--suffix-format",
            "arg": null,
            "description": "use sprintf FORMAT instead of %02d"
        },
        {
            "flag": "-f",
            "long": "--prefix",
            "arg": null,
            "description": "use PREFIX instead of 'xx'"
        },
        {
            "flag": "-k",
            "long": "--keep-files",
            "arg": null,
            "description": "do not remove output files on errors"
        },
        {
            "flag": "",
            "long": "--suppress-matched",
            "arg": null,
            "description": "suppress the lines matching PATTERN"
        },
        {
            "flag": "-n",
            "long": "--digits",
            "arg": null,
            "description": "use specified number of digits instead of 2"
        },
        {
            "flag": "-s",
            "long": "--silent",
            "arg": null,
            "description": "do not print counts of output file sizes"
        },
        {
            "flag": "-z",
            "long": "--elide-empty-files",
            "arg": null,
            "description": "remove empty output files --help display this help and exit"
        },
        {
            "flag": "",
            "long": "--version",
            "arg": null,
            "description": "output version information and exit"
        }
    ],
    "examples": [],
    "see_also": [],
    "tldr": {
        "source": "official",
        "description": "Split a file into pieces.",
        "examples": [
            {
                "description": "Split a file in two parts, starting the second one at line 10",
                "command": "csplit {{path/to/file}} 10"
            },
            {
                "description": "Split a file in three parts, starting the latter parts in lines 7 and 23",
                "command": "csplit {{path/to/file}} 7 23"
            },
            {
                "description": "Start a new part at every 5th line (will fail if number of lines is not divisible by 5)",
                "command": "csplit {{path/to/file}} 5 {*}"
            },
            {
                "description": "Start a new part at every 5th line, ignoring exact-division error",
                "command": "csplit {{-k|--keep-files}} {{path/to/file}} 5 {*}"
            },
            {
                "description": "Split a file above line 5 and use a custom prefix for the output files (default is `xx`)",
                "command": "csplit {{path/to/file}} 5 {{-f|--prefix}} {{prefix}}"
            },
            {
                "description": "Split a file above the first line matching a `regex` pattern",
                "command": "csplit {{path/to/file}} /{{regex}}/"
            }
        ]
    }
}