mktemp: fix `common` and standardize between variants (#10700)

* mktemp: fix `common` and standardize variants
* mktemp: add -p example
* linux/mktemp: add -p example
* linux/mktemp: mention `$TMPDIR` in the `-p` example
* osx/mktemp: add page
* linux/mktemp: fix errors
* linux/mktemp: add serial comma
pull/23/head
pixel 2023-10-03 14:53:31 +02:00 committed by GitHub
parent d8fb645ac2
commit f8d6aa88dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 56 additions and 17 deletions

View File

@ -1,16 +1,24 @@
# mktemp
> Create a temporary file or directory.
> More information: <https://ss64.com/osx/mktemp.html>.
> More information: <https://man.openbsd.org/mktemp.1>.
- Create an empty temporary file and print the absolute path to it:
- Create an empty temporary file and print its absolute path:
`mktemp`
- Create an empty temporary file with a given suffix and print the absolute path to file:
- Use a custom directory if `$TMPDIR` is not set (the default is platform-dependent, but usually `/tmp`):
`mktemp --suffix "{{.ext}}"`
`mktemp -p {{/path/to/tempdir}}`
- Create a temporary directory and print the absolute path to it:
- 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:
`mktemp -d`

View File

@ -1,21 +1,28 @@
# mktemp
> Create a temporary file or directory.
> Note that examples here all assume `$TMPDIR` is unset.
> More information: <https://www.gnu.org/software/autogen/mktemp.html>.
> More information: <https://www.gnu.org/software/coreutils/mktemp>.
- Create an empty temporary file in `/tmp/` and print its absolute path:
- Create an empty temporary file and print its absolute path:
`mktemp`
- Create a temporary directory in `/tmp/` and print its absolute path:
- Use a custom directory (defaults to `$TMPDIR`, or `/tmp`):
`mktemp --tmpdir={{/path/to/tempdir}}`
- 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 file with the given suffix and print its absolute path:
`mktemp --suffix {{.ext}}`
- Create an empty temporary directory and print its absolute path:
`mktemp --directory`
- Create an empty temporary file at the specified path, with `X`s replaced with random alphanumeric characters, and print its path:
`mktemp "{{path/to/file_XXXXX_name}}"`
- Create an empty temporary file in `/tmp/` with the specified name, with `X`s replaced with random alphanumeric characters, and print its path:
`mktemp -t "{{file_XXXXX_name}}"`

24
pages/osx/mktemp.md Normal file
View File

@ -0,0 +1,24 @@
# mktemp
> Create a temporary file or directory.
> More information: <https://keith.github.io/xcode-man-pages/mktemp.1.html>.
- Create an empty temporary file and print its absolute path:
`mktemp`
- Use a custom directory (defaults to the output of `getconf DARWIN_USER_TEMP_DIR`, or `/tmp`):
`mktemp --tmpdir={{/path/to/tempdir}}`
- Use a custom path template (`X`s are replaced with random alphanumeric characters):
`mktemp {{/tmp/example.XXXXXXXX}}`
- Use a custom file name prefix:
`mktemp -t {{example}}`
- Create an empty temporary directory and print its absolute path:
`mktemp --directory`