From d6e6d96d92768bcb66f9c20cfb99371c89511219 Mon Sep 17 00:00:00 2001 From: exu Date: Sat, 29 Jul 2023 15:22:32 +0200 Subject: [PATCH] Add info for `mktemp` command --- pages/04.other/useful-commands/default.en.md | 42 ++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/pages/04.other/useful-commands/default.en.md b/pages/04.other/useful-commands/default.en.md index 5a2173f..e7e5e6d 100644 --- a/pages/04.other/useful-commands/default.en.md +++ b/pages/04.other/useful-commands/default.en.md @@ -152,3 +152,45 @@ touch -a -m -d "2023-07-29T00:23" > [Linux - modify file modify/access/change time](https://stackoverflow.com/questions/40630695/linux-modify-file-modify-access-change-time) > [How can I change the date modified/created of a file?](https://askubuntu.com/questions/62492/how-can-i-change-the-date-modified-created-of-a-file) + +### Create a random temporary directory / file + +Using `mktemp`, a randomly named file or directory will be created in `/tmp` + +Create a file: +[shuser] + +```sh +mktemp +``` + +[/shuser] + +Create a directory: +[shuser] + +```sh +mktemp -d +``` + +[/shuser] + +Save the output into an environment variable for future referencing + +sh / Bash: +[shuser] + +```sh +export TMPDIR=$(mktemp -d) +``` + +[/shuser] + +Fish: +[shuser] + +```fish +set TMPDIR (mktemp -d) +``` + +[/shuser]