May 2017
Beginner
552 pages
28h 47m
English
The mktemp command will create a unique temporary file or folder name:
$ filename=`mktemp`
$ echo $filename
/tmp/tmp.8xvhkjF5fH
This creates a temporary file, stores the name in filename, and then displays the name.
$ dirname=`mktemp -d`
$ echo $dirname
tmp.NI8xzW7VRX
This creates a temporary directory, stores the name in filename, and displays the name.
$ tmpfile=`mktemp -u`
$ echo $tmpfile
/tmp/tmp.RsGmilRpcT
Here, the filename is stored in $tmpfile, but the file won't be created.
$mktemp test.XXX
test.2tc