mktemp for filesystem
Create temporary files or directories using uutils/coreutils mktemp.
Signature
> mktemp {flags} (template)
Flags
--suffix {string}: Append suffix to template; must not contain a slash.--tmpdir-path, -p {path}: Interpret TEMPLATE relative to tmpdir-path. If tmpdir-path is not set use $TMPDIR--tmpdir, -t: Interpret TEMPLATE relative to the system temporary directory.--directory, -d: Create a directory instead of a file.
Parameters
template: Optional pattern from which the name of the file or directory is derived. Must contain at least three 'X's in last component.
Input/output types:
| input | output |
|---|---|
| nothing | string |
Examples
Make a temporary file with the given suffix in the current working directory.
> mktemp --suffix .txt
<WORKING_DIR>/tmp.lekjbhelyx.txtMake a temporary file named testfile.XXX with the 'X's as random characters in the current working directory.
> mktemp testfile.XXX
<WORKING_DIR>/testfile.4khMake a temporary file with a template in the system temp directory.
> mktemp -t testfile.XXX
/tmp/testfile.4khMake a temporary directory with randomly generated name in the temporary directory.
> mktemp -d
/tmp/tmp.NMw9fJr8K0