I try to understand Stephen Kitt's answer to this question where he created a temporary directory with the following code:
#!/bin/bash
scripttmp=$(mktemp -d) # Create a temporary directory (these will usually be created under /tmp or /var/tmp/)
Each time I run this command I see a new temporary directory created under /tmp/
(I didn't know it will appear there until reading Roaima's answer here):
IIUC, there is no programmatical difference between a regular directory to a temporary directory (the only difference is in how these directories are used, by means of the time each one stays on the machine).
If there is no programmatical difference, why should one prefer mktemp -d
over the more minimal mkdir
?
mktemp
when added security matters. – Daniele Santi Sep 26 '18 at 13:24mktemp -d
easier to use. – prosti Sep 26 '18 at 19:09