Skip to main content

Create a temporary file or directory.

# To create an empty temporary file and print its absolute path:
mktemp

# To use a custom directory if '$TMPDIR' is not set (the default is platform-dependent, but usually '/tmp'):
mktemp -p </path/to/tempdir>

# To use a custom path template ('X's are replaced with random alphanumeric characters):
mktemp </tmp/example.XXXXXXXX>

# To use a custom file name template:
mktemp -t <example.XXXXXXXX>

# To create an empty temporary directory and print its absolute path:
mktemp -d