2022-03-16 17:02:09 +00:00
|
|
|
# mktemp
|
|
|
|
|
|
|
|
> Create a temporary file or directory.
|
2023-10-03 13:53:31 +01:00
|
|
|
> More information: <https://www.gnu.org/software/coreutils/mktemp>.
|
2022-03-16 17:02:09 +00:00
|
|
|
|
2023-10-03 13:53:31 +01:00
|
|
|
- Create an empty temporary file and print its absolute path:
|
2022-03-16 17:02:09 +00:00
|
|
|
|
|
|
|
`mktemp`
|
|
|
|
|
2023-10-03 13:53:31 +01:00
|
|
|
- Use a custom directory (defaults to `$TMPDIR`, or `/tmp`):
|
2022-03-16 17:02:09 +00:00
|
|
|
|
2023-10-03 13:53:31 +01: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-16 17:02:09 +00:00
|
|
|
|
2023-10-03 13:53:31 +01:00
|
|
|
- Use a custom file name template:
|
2022-03-16 17:02:09 +00:00
|
|
|
|
2023-10-03 13:53:31 +01:00
|
|
|
`mktemp -t {{example.XXXXXXXX}}`
|
2023-08-31 14:47:51 +01:00
|
|
|
|
2023-10-03 13:53:31 +01:00
|
|
|
- Create an empty temporary file with the given suffix and print its absolute path:
|
2023-08-31 14:47:51 +01:00
|
|
|
|
2023-10-03 13:53:31 +01:00
|
|
|
`mktemp --suffix {{.ext}}`
|
|
|
|
|
|
|
|
- Create an empty temporary directory and print its absolute path:
|
|
|
|
|
|
|
|
`mktemp --directory`
|