Linux "tempfile" Command Line Options and Examples
create a temporary file in a safe manner

tempfile creates a temporary file in a safe manner. It uses tempnam(3) to choose the name and opens it with O_RDWR | O_CREAT | O_EXCL. The filename is printed on standard output.


Usage:

tempfile [-d DIR] [-p STRING] [-s STRING] [-m MODE] [-n FILE] [--directory=DIR] [--prefix=STRING] [--suf‐
    fix=STRING] [--mode=MODE] [--name=FILE] [--help] [--version]






Command Line Options:

-d
Place the file in DIR.
tempfile -d ...
-m
Open the file with MODE instead of 0600.
tempfile -m ...
-n
Use FILE for the name instead of tempnam(3). The options -d, -p, and -s are ignored if this option isgiven.
tempfile -n ...
-p
Use up to five letters of STRING to generate the name.
tempfile -p ...
-s
Generate the file with STRING as the suffix.
tempfile -s ...
--help
Print a usage message on standard output and exit successfully.
tempfile --help ...
--version
Print version information on standard output and exit successfully.RETURN VALUESAn exit status of 0 means the temporary file was created successfully. Any other exit status indicates anerror.BUGSExclusive creation is not guaranteed when creating files on NFS partitions. tempfile cannot make temporarydirectories. tempfile is deprecated; you should use mktemp(1) instead.EXAMPLE#!/bin/sh#[...]t=$(tempfile) || exittrap "rm -f -- '$t'" EXIT#[...]rm -f -- "$t"trap - EXITexit
tempfile --version ...