Open ltog opened 8 years ago
Draft to create temporary directory and a temporary file in it:
#!/bin/bash
tmpdir=$(mktemp --tmpdir --directory "$(basename ${0})-XXXXXXXXXX") || {
echo "ERROR: Could not create temporary directory.";
cleanup
exit 1;
}
tmpfile=$(mktemp --tmpdir="$tmpdir" "asdf-XXXXXXXXXXXXXXXXXX") || {
echo "ERROR: Could not create temporary file.";
cleanup
exit 1;
}
echo tmpfile=$tmpfile
Note: The closing curly brace must end on a new line.
Creation of temporary files and directories in scripts should be done using
mktemp
, especially in those usingparallel
.