From 812e4caf36d84c55db69b4fc3e47216f8b3b7aca Mon Sep 17 00:00:00 2001 From: Michele Cereda Date: Wed, 20 Apr 2022 21:02:37 +0200 Subject: [PATCH] Added mktemp notes to the knowledge base --- knowledge base/mktemp.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 knowledge base/mktemp.md diff --git a/knowledge base/mktemp.md b/knowledge base/mktemp.md new file mode 100644 index 0000000..b6dc917 --- /dev/null +++ b/knowledge base/mktemp.md @@ -0,0 +1,31 @@ +# Mktemp + +Creates a unique temporary file or directory and returns the absolute path to it. + +## TL;DR + +```shell +# create an empty temporary file +mktemp + +# create an empty temporary directory +mktemp -d + +# create an empty temporary file or directory with a random templated name +# the Xs must be put at the end of the filename +# the Xs specifies the templated parts and lenght in the file name +mktemp /tmp/filenameXXX +mktemp -d /tmp/dirname.XXX + +# create an empty temporary file or directory with a specified suffix (GNU only) +mktemp --suffix ".txt" + +# create an empty temporary file or directory with a specified prefix +mktemp -t "txt" +``` + +## Further readings + +- [Man page] + +[man page]: https://www.gnu.org/software/autogen/mktemp.html