From 8695f2cc1524f46d82a7e5aa453d24ae6627ef3c Mon Sep 17 00:00:00 2001 From: cyqsimon <28627918+cyqsimon@users.noreply.github.com> Date: Thu, 31 Aug 2023 21:47:51 +0800 Subject: [PATCH] mktemp(linux): improve examples (#10652) --- pages/linux/mktemp.md | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/pages/linux/mktemp.md b/pages/linux/mktemp.md index 999e7c693..8ae89853c 100644 --- a/pages/linux/mktemp.md +++ b/pages/linux/mktemp.md @@ -1,16 +1,21 @@ # mktemp > Create a temporary file or directory. +> Note that examples here all assume `$TMPDIR` is unset. > More information: . -- Create an empty temporary file and print the absolute path to it: +- Create an empty temporary file in `/tmp/` and print its absolute path: `mktemp` -- Create an empty temporary file with a given suffix and print the absolute path to file: - -`mktemp --suffix "{{.ext}}"` - -- Create a temporary directory and print the absolute path to it: +- Create a temporary directory in `/tmp/` 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}}"`