mktemp
FilesAdvanced In simulator In real LinuxCreate a temporary file or directory safely
Name: mktemp = make temporary
You can practise it right away in the simulator, and use it in real Linux mode too.
Description
mktemp safely creates a temporary file (or with -d a directory) with a random, unique name and prints its path. Scripts should use it instead of fixed names like /tmp/xxx to avoid clashes and security issues.
Syntax
mktemp [OPTION]... [TEMPLATE]Common options
| -d / --directory | Create a directory |
| -p / --tmpdir DIR | Create it in DIR ($TMPDIR or /tmp by default) |
| --suffix SUFFIX | Add SUFFIX to the name, e.g. --suffix=.txt |
| -u / --dry-run | Print a name without creating it (unsafe: someone may take it first) |
| XXXXXX | X characters in the template become random |