I wonder if you actually mean shell variables, or temporary files.
If what you're doing is this (a temporary file):
something > "$tmp"
something else < "$tmp"
Then sure, go ahead and remove the temp file after you're done. Though if the script crashes in the middle, the file will be left laying there, but that's not exactly uncommon either. You could use
trap 'rm "$tmp"' EXIT to remove the file when the shell exits, if you care.
But I don't see a reason to use
-f, let alone
(Also, remember to quote the variable, even though
mktemp by default makes "nice" filenames.)
However, if you're doing this (a variable):
do something with "$var"
Then you don't want to do that: you have no file to remove, just something entered by the user. Shell variables cease to exist when the shell exits, so no need to unset them.
Though if your script is meant to be sourced from another shell (or it's in
.bashrc or similar), the shell doesn't exit when your script ends. In that case it might be useful to
unset any temporary variables you used at the end, to not leave them set for the rest of the shell's lifetime.
# in .bashrc
if [ "$__hour" -lt 12 ] ; then echo "Good Morning!" ;
elif [ "$__hour" -gt 18 ] ; then echo "Good Evening!" ;
The variable name might still collide with some variable used outside that script so some care must be taken with naming.