Useful tip, I suppose it will look like:
temp=$(mktemp) trap 'unlink $temp' EXIT # Do things
Exactly. And if your cleanup is more involved you can call a cleanup function.