Add info for mktemp command

This commit is contained in:
exu 2023-07-29 15:22:32 +02:00
parent d15b3d3b7c
commit d6e6d96d92

View File

@ -152,3 +152,45 @@ touch -a -m -d "2023-07-29T00:23" <file>
> [Linux - modify file modify/access/change time](https://stackoverflow.com/questions/40630695/linux-modify-file-modify-access-change-time) > [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) > [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]