Name
mktemp
Synopsis
mktemp [options
]template
Generate a unique temporary filename for use in a script.
The filename is based on the specified template, which may be any
filename with at least six X
s
appended (e.g., /tmp/mytemp.XXXXXX
). mktemp replaces the X
s with the current process number
and/or a unique letter combination. The file is created with mode
0600 (unless -u
is specified) and the filename is
written to standard output.
Common Options
-
-d
Make a directory, not a file.
-
-q
Fail silently in case of error. Useful to prevent error output from being sent to standard error.
-
-u
Operate in “unsafe” mode and unlink the temporary file before mktemp exits. Use of this option is not recommended.
Solaris and GNU/Linux Options
-
-p
prefix
Use prefix as the directory for the temporary filename. The TMPDIR environment variable overrides this option. Implies
-t
.-
-t
Create a path in a temporary directory. The directory name is the first of: the TMPDIR environment variable; the value of prefix given to
-p
; or /tmp.
GNU/Linux Option
-
-V
Print version information and exit.
Mac OS X Option
-t
[
prefix
]Like Solaris
-p
, except that the prefix is optional.
Get Unix in a Nutshell, 4th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.