tldr/pages/common/mktemp.md

25 lines
594 B
Markdown
Raw Normal View History

2017-05-26 10:28:13 +01:00
# mktemp
> Create a temporary file or directory.
> More information: <https://man.openbsd.org/mktemp.1>.
2017-05-26 10:28:13 +01:00
- Create an empty temporary file and print its absolute path:
2017-05-26 10:28:13 +01:00
`mktemp`
- 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
`mktemp -p {{/path/to/tempdir}}`
2017-05-26 10:28:13 +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`