Dropping temporary files without cleaning them up is a little untidy; at the end of a script where temporary files are used, we should have a safe rm command to remove them afterward:
#!/bin/bash
# Code setting and using tempdir goes here, and then ...
# Remove the directory
if [[ -n $tempdir ]] ; then rm -- "$tempdir"/myscript-timestamp rmdir -- "$tempdir" fi
Notice that we're careful to check that tempdir actually has a value, using the -n test before we run this code, even if we don't think anything might have changed it; otherwise we'd be running rm -- /myscript-timestamp.
Notice also that we're carefully removing only the files we know we've created, rather than just specifying "$tempdir"/*. An empty value for the tempdir variable in such a case could have terrible consequences!
The preceding...