{
    "mode": "man",
    "parameter": "TRUNCATE",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/TRUNCATE/1/json",
    "generated": "2026-10-04T22:07:00Z",
    "synopsis": "truncate OPTION... FILE...",
    "sections": {
        "NAME": {
            "content": "truncate - shrink or extend the size of a file to the specified size\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "truncate OPTION... FILE...\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Shrink or extend the size of each FILE to the specified size\n\nA FILE argument that does not exist is created.\n\nIf  a  FILE is larger than the specified size, the extra data is lost.  If a FILE is shorter,\nit is extended and the sparse extended part (hole) reads as zero bytes.\n\nMandatory arguments to long options are mandatory for short options too.\n",
            "subsections": [
                {
                    "name": "-c --no-create",
                    "content": "do not create any files\n",
                    "flag": "-c",
                    "long": "--no-create"
                },
                {
                    "name": "-o --io-blocks",
                    "content": "treat SIZE as number of IO blocks instead of bytes\n",
                    "flag": "-o",
                    "long": "--io-blocks"
                },
                {
                    "name": "-r --reference",
                    "content": "base size on RFILE\n",
                    "flag": "-r",
                    "long": "--reference"
                },
                {
                    "name": "-s --size",
                    "content": "set or adjust the file size by SIZE bytes\n\n--help display this help and exit\n",
                    "flag": "-s",
                    "long": "--size"
                },
                {
                    "name": "--version",
                    "content": "output version information and exit\n\nThe SIZE argument is an integer and optional unit  (example:  10K  is  10*1024).   Units  are\nK,M,G,T,P,E,Z,Y,R,Q  (powers  of 1024) or KB,MB,... (powers of 1000).  Binary prefixes can be\nused, too: KiB=K, MiB=M, and so on.\n\nSIZE may also be prefixed by one of the following modifying characters: '+'  extend  by,  '-'\nreduce by, '<' at most, '>' at least, '/' round down to multiple of, '%' round up to multiple\nof.\n",
                    "long": "--version"
                }
            ]
        },
        "AUTHOR": {
            "content": "Written by Padraig Brady.\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  ©  2023 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": "dd(1), truncate(2), ftruncate(2)\n\nFull documentation <https://www.gnu.org/software/coreutils/truncate>\nor available locally via: info '(coreutils) truncate invocation'\n\nGNU coreutils 9.4                           January 2026                                 TRUNCATE(1)",
            "subsections": []
        }
    },
    "summary": "truncate - shrink or extend the size of a file to the specified size",
    "flags": [
        {
            "flag": "-c",
            "long": "--no-create",
            "arg": null,
            "description": "do not create any files"
        },
        {
            "flag": "-o",
            "long": "--io-blocks",
            "arg": null,
            "description": "treat SIZE as number of IO blocks instead of bytes"
        },
        {
            "flag": "-r",
            "long": "--reference",
            "arg": null,
            "description": "base size on RFILE"
        },
        {
            "flag": "-s",
            "long": "--size",
            "arg": null,
            "description": "set or adjust the file size by SIZE bytes --help display this help and exit"
        },
        {
            "flag": "",
            "long": "--version",
            "arg": null,
            "description": "output version information and exit The SIZE argument is an integer and optional unit (example: 10K is 10*1024). Units are K,M,G,T,P,E,Z,Y,R,Q (powers of 1024) or KB,MB,... (powers of 1000). Binary prefixes can be used, too: KiB=K, MiB=M, and so on. SIZE may also be prefixed by one of the following modifying characters: '+' extend by, '-' reduce by, '<' at most, '>' at least, '/' round down to multiple of, '%' round up to multiple of."
        }
    ],
    "examples": [],
    "see_also": [
        {
            "name": "dd",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/dd/1/json"
        },
        {
            "name": "truncate",
            "section": "2",
            "url": "https://www.chedong.com/phpMan.php/man/truncate/2/json"
        },
        {
            "name": "ftruncate",
            "section": "2",
            "url": "https://www.chedong.com/phpMan.php/man/ftruncate/2/json"
        }
    ],
    "tldr": {
        "source": "official",
        "description": "Shrink or extend the size of a file to the specified size.",
        "examples": [
            {
                "description": "Set a size of 10 GB to an existing file, or create a new file with the specified size",
                "command": "truncate {{-s|--size}} 10G {{path/to/file}}"
            },
            {
                "description": "Extend the file size by 50 MiB, fill with holes (which reads as zero bytes)",
                "command": "truncate {{-s|--size}} +50M {{path/to/file}}"
            },
            {
                "description": "Shrink the file by 2 GiB, by removing data from the end of file",
                "command": "truncate {{-s|--size}} -2G {{path/to/file}}"
            },
            {
                "description": "Empty the file's content",
                "command": "truncate {{-s|--size}} 0 {{path/to/file}}"
            },
            {
                "description": "Empty the file's content, but do not create the file if it does not exist",
                "command": "truncate {{-s|--size}} 0 {{-c|--no-create}} {{path/to/file}}"
            }
        ]
    }
}