{
    "content": [
        {
            "type": "text",
            "text": "# tempfile(1) (man)\n\n## NAME\n\ntempfile - create a temporary file in a safe manner\n\n## SYNOPSIS\n\ntempfile  [-d  DIR]  [-p  STRING]  [-s  STRING] [-m MODE] [-n FILE] [--directory=DIR] [--pre‐\nfix=STRING] [--suffix=STRING] [--mode=MODE] [--name=FILE] [--help] [--version]\n\n## DESCRIPTION\n\ntempfile creates a temporary file in a safe manner.  It uses mkstemps(3) to choose  the  name\nand opens it with ORDWR | OCREAT | OEXCL.  The filename is printed on standard output.\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **OPTIONS** (6 subsections)\n- **RETURN VALUES**\n- **BUGS**\n- **EXAMPLE**\n- **SEE ALSO**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "tempfile",
        "section": "1",
        "mode": "man",
        "summary": "tempfile - create a temporary file in a safe manner",
        "synopsis": "tempfile  [-d  DIR]  [-p  STRING]  [-s  STRING] [-m MODE] [-n FILE] [--directory=DIR] [--pre‐\nfix=STRING] [--suffix=STRING] [--mode=MODE] [--name=FILE] [--help] [--version]",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [
            {
                "flag": "-d",
                "long": "--directory",
                "arg": null,
                "description": "Place the file in DIR."
            },
            {
                "flag": "-m",
                "long": "--mode",
                "arg": null,
                "description": "Open the file with MODE instead of 0600."
            },
            {
                "flag": "-n",
                "long": "--name",
                "arg": null,
                "description": "Use FILE for the name instead of tempnam(3). The options -d, -p, and -s are ignored if this option is given."
            },
            {
                "flag": "-p",
                "long": "--prefix",
                "arg": null,
                "description": "Use up to five letters of STRING to generate the name."
            },
            {
                "flag": "-s",
                "long": "--suffix",
                "arg": null,
                "description": "Generate the file with STRING as the suffix. --help Print a usage message on standard output and exit successfully."
            },
            {
                "flag": "",
                "long": "--version",
                "arg": null,
                "description": "Print version information on standard output and exit successfully."
            }
        ],
        "examples": [
            "#!/bin/sh",
            "#[...]",
            "t=$(tempfile) || exit",
            "trap \"rm -f -- '$t'\" EXIT",
            "#[...]",
            "rm -f -- \"$t\"",
            "trap - EXIT",
            "exit"
        ],
        "see_also": [
            {
                "name": "tempnam",
                "section": "3",
                "url": "https://www.chedong.com/phpMan.php/man/tempnam/3/json"
            },
            {
                "name": "mktemp",
                "section": "1",
                "url": "https://www.chedong.com/phpMan.php/man/mktemp/1/json"
            }
        ],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 14,
                "subsections": []
            },
            {
                "name": "OPTIONS",
                "lines": 1,
                "subsections": [
                    {
                        "name": "-d, --directory",
                        "lines": 2,
                        "flag": "-d",
                        "long": "--directory"
                    },
                    {
                        "name": "-m, --mode",
                        "lines": 2,
                        "flag": "-m",
                        "long": "--mode"
                    },
                    {
                        "name": "-n, --name",
                        "lines": 3,
                        "flag": "-n",
                        "long": "--name"
                    },
                    {
                        "name": "-p, --prefix",
                        "lines": 2,
                        "flag": "-p",
                        "long": "--prefix"
                    },
                    {
                        "name": "-s, --suffix",
                        "lines": 4,
                        "flag": "-s",
                        "long": "--suffix"
                    },
                    {
                        "name": "--version",
                        "lines": 2,
                        "long": "--version"
                    }
                ]
            },
            {
                "name": "RETURN VALUES",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "BUGS",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "EXAMPLE",
                "lines": 9,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 5,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "tempfile - create a temporary file in a safe manner\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "tempfile  [-d  DIR]  [-p  STRING]  [-s  STRING] [-m MODE] [-n FILE] [--directory=DIR] [--pre‐\nfix=STRING] [--suffix=STRING] [--mode=MODE] [--name=FILE] [--help] [--version]\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "tempfile creates a temporary file in a safe manner.  It uses mkstemps(3) to choose  the  name\nand opens it with ORDWR | OCREAT | OEXCL.  The filename is printed on standard output.\n\nThe directory in which to create the file might be searched for in this order:\n\na) In case the environment variable TMPDIR exists and contains the name of an appropriate di‐\nrectory, that is used.\n\nb) Otherwise, if the --directory argument is specified and appropriate, it is used.\n\nc) Otherwise, Ptmpdir (as defined in <stdio.h>) is used when appropriate.\n\nd) Finally an implementation-defined directory (/tmp) may be used.\n",
                "subsections": []
            },
            "OPTIONS": {
                "content": "",
                "subsections": [
                    {
                        "name": "-d, --directory",
                        "content": "Place the file in DIR.\n",
                        "flag": "-d",
                        "long": "--directory"
                    },
                    {
                        "name": "-m, --mode",
                        "content": "Open the file with MODE instead of 0600.\n",
                        "flag": "-m",
                        "long": "--mode"
                    },
                    {
                        "name": "-n, --name",
                        "content": "Use FILE for the name instead of tempnam(3).  The options -d, -p, and -s  are  ignored\nif this option is given.\n",
                        "flag": "-n",
                        "long": "--name"
                    },
                    {
                        "name": "-p, --prefix",
                        "content": "Use up to five letters of STRING to generate the name.\n",
                        "flag": "-p",
                        "long": "--prefix"
                    },
                    {
                        "name": "-s, --suffix",
                        "content": "Generate the file with STRING as the suffix.\n\n--help Print a usage message on standard output and exit successfully.\n",
                        "flag": "-s",
                        "long": "--suffix"
                    },
                    {
                        "name": "--version",
                        "content": "Print version information on standard output and exit successfully.\n",
                        "long": "--version"
                    }
                ]
            },
            "RETURN VALUES": {
                "content": "An exit status of 0 means the temporary file was created successfully.  Any other exit status\nindicates an error.\n",
                "subsections": []
            },
            "BUGS": {
                "content": "Exclusive creation is not guaranteed when creating files on NFS partitions.  tempfile  cannot\nmake temporary directories.  tempfile is deprecated; you should use mktemp(1) instead.\n",
                "subsections": []
            },
            "EXAMPLE": {
                "content": "#!/bin/sh\n#[...]\nt=$(tempfile) || exit\ntrap \"rm -f -- '$t'\" EXIT\n#[...]\nrm -f -- \"$t\"\ntrap - EXIT\nexit\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "tempnam(3), mktemp(1)\n\n\n\nDebian                                       27 Jun 2012                                 TEMPFILE(1)",
                "subsections": []
            }
        }
    }
}