Scroll to navigation

mktemp(1) General Commands Manual mktemp(1)

NAME

mktemp - Create a temporary file or directory.

SYNOPSIS

mktemp [-d|--directory] [-u|--dry-run] [-q|--quiet] [--suffix] [-p ] [--tmpdir] [-t ] [-h|--help] [-V|--version] [template]

DESCRIPTION

Create a temporary file or directory.

OPTIONS

Make a directory instead of a file
do not create anything; merely print a name (unsafe)
Fail silently if an error occurs.
append SUFFIX to TEMPLATE; SUFFIX must not contain a path separator. This option is implied if TEMPLATE does not end with X.
short form of --tmpdir
interpret TEMPLATE relative to DIR; if DIR is not specified, use $TMPDIR ($TMP on windows) if set, else /tmp. With this option, TEMPLATE must not be an absolute name; unlike with -t, TEMPLATE may contain slashes, but mktemp creates only the final component
Generate a template (using the supplied prefix and TMPDIR (TMP on windows) if set) to create a filename template [deprecated]
Print help
Print version
[template]

VERSION

v(uutils coreutils) 0.7.0

EXAMPLES

Create an empty temporary file and print its absolute path:

mktemp

Use a custom directory if `$TMPDIR` is not set (the default is platform-dependent, but usually `/tmp`):

mktemp -p /path/to/temporary_directory

Use a custom path template (`X`s are replaced with random alphanumeric characters):

mktemp /tmp/example.XXXXXXXX

Use a custom file name template:

mktemp -t example.XXXXXXXX

Create an empty temporary directory and print its absolute path:

mktemp -d

The examples are provided by the tldr-pages project <https://tldr.sh> under the CC BY 4.0 License. Please note that, as uutils is a work in progress, some examples might fail.

mktemp (uutils coreutils) 0.7.0