2017-05-26 10:28:13 +01:00
|
|
|
# mktemp
|
|
|
|
|
|
|
|
> Create a temporary file or directory.
|
2023-10-03 13:53:31 +01:00
|
|
|
> More information: <https://man.openbsd.org/mktemp.1>.
|
2017-05-26 10:28:13 +01:00
|
|
|
|
2023-10-03 13:53:31 +01:00
|
|
|
- Create an empty temporary file and print its absolute path:
|
2017-05-26 10:28:13 +01:00
|
|
|
|
|
|
|
`mktemp`
|
|
|
|
|
2023-10-03 13:53:31 +01:00
|
|
|
- Use a custom directory if `$TMPDIR` is not set (the default is platform-dependent, but usually `/tmp`):
|
2017-05-26 10:28:13 +01:00
|
|
|
|
2023-10-03 13:53:31 +01:00
|
|
|
`mktemp -p {{/path/to/tempdir}}`
|
2017-05-26 10:28:13 +01:00
|
|
|
|
2023-10-03 13:53:31 +01:00
|
|
|
- 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:
|
2017-05-26 10:28:13 +01:00
|
|
|
|
2022-01-26 23:22:54 +00:00
|
|
|
`mktemp -d`
|