Back to the learning path

mktemp

mktemp = make temporary Command details
Step 1/1: Safe temporary files

mktemp creates a temporary file with a random, unique name and prints its path; -d makes a directory. Scripts often do tmp=$(mktemp -d) and delete it at the end.

$ mktemp -d /tmp/build.XXXXXX
Fundamentalsmktemp
Make a temporary directory
Use mktemp to create a temporary directory in /tmp named scratch. followed by 6 random characters, and print its path.