From f8d6aa88dcbb2d5bcb046ce6a8455f023e2f8c38 Mon Sep 17 00:00:00 2001 From: pixel Date: Tue, 3 Oct 2023 14:53:31 +0200 Subject: [PATCH] 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 --- pages/common/mktemp.md | 18 +++++++++++++----- pages/linux/mktemp.md | 31 +++++++++++++++++++------------ pages/osx/mktemp.md | 24 ++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 17 deletions(-) create mode 100644 pages/osx/mktemp.md diff --git a/pages/common/mktemp.md b/pages/common/mktemp.md index 3373a12a9..c36855497 100644 --- a/pages/common/mktemp.md +++ b/pages/common/mktemp.md @@ -1,16 +1,24 @@ # mktemp > Create a temporary file or directory. -> More information: . +> More information: . -- 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` diff --git a/pages/linux/mktemp.md b/pages/linux/mktemp.md index 8ae89853c..d94a3b231 100644 --- a/pages/linux/mktemp.md +++ b/pages/linux/mktemp.md @@ -1,21 +1,28 @@ # mktemp > Create a temporary file or directory. -> Note that examples here all assume `$TMPDIR` is unset. -> More information: . +> More information: . -- 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}}"` diff --git a/pages/osx/mktemp.md b/pages/osx/mktemp.md new file mode 100644 index 000000000..022518d4e --- /dev/null +++ b/pages/osx/mktemp.md @@ -0,0 +1,24 @@ +# mktemp + +> Create a temporary file or directory. +> More information: . + +- 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`