function cleanexit {} - Clean your shit!
Posted on Thu, Mar 31, 2022 at 16:07 by Hubertus A. HanielWhen writing scripts that create temporary files I prefer to stick a clean exit function at the top of the script that runs the clean up no matter how the script exits - this should even remove files when the script got interrupted:
function cleanexit
{
rm -f /var/tmp/tmpfile
}
trap cleanexit INT QUIT TERM EXIT
Let me know if you have a better idea!