2022-03-17 03:02:09 +10:00
|
|
|
# mktemp
|
|
|
|
|
|
|
|
> Create a temporary file or directory.
|
2025-01-18 18:45:33 +05:30
|
|
|
> More information: <https://www.gnu.org/software/coreutils/manual/html_node/mktemp-invocation.html>.
|
2022-03-17 03:02:09 +10:00
|
|
|
|
2023-10-03 14:53:31 +02:00
|
|
|
- Create an empty temporary file and print its absolute path:
|
2022-03-17 03:02:09 +10:00
|
|
|
|
|
|
|
`mktemp`
|
|
|
|
|
2023-10-03 14:53:31 +02:00
|
|
|
- Use a custom directory (defaults to `$TMPDIR`, or `/tmp`):
|
2022-03-17 03:02:09 +10:00
|
|
|
|
2023-10-03 14:53:31 +02:00
|
|
|
`mktemp --tmpdir={{/path/to/tempdir}}`
|
|
|
|
|
|
|
|
- Use a custom path template (`X`s are replaced with random alphanumeric characters):
|
|
|
|
|
|
|
|
`mktemp {{/tmp/example.XXXXXXXX}}`
|
2022-03-17 03:02:09 +10:00
|
|
|
|
2023-10-03 14:53:31 +02:00
|
|
|
- Use a custom file name template:
|
2022-03-17 03:02:09 +10:00
|
|
|
|
2023-10-03 14:53:31 +02:00
|
|
|
`mktemp -t {{example.XXXXXXXX}}`
|
2023-08-31 21:47:51 +08:00
|
|
|
|
2023-10-03 14:53:31 +02:00
|
|
|
- Create an empty temporary file with the given suffix and print its absolute path:
|
2023-08-31 21:47:51 +08:00
|
|
|
|
2023-10-03 14:53:31 +02:00
|
|
|
`mktemp --suffix {{.ext}}`
|
|
|
|
|
|
|
|
- Create an empty temporary directory and print its absolute path:
|
|
|
|
|
|
|
|
`mktemp --directory`
|