trap#
Usage#
Use trap to clean up temporary files or resources when a script receives a signal.
TMPFILE1=$(mktemp /tmp/im1.XXXXXX)
TMPFILE2=$(mktemp /tmp/im2.XXXXXX)
# Delete temp files on interrupt (`Ctrl+C`)
trap "rm -f $TMPFILE1 $TMPFILE2; exit 1" INTSignals#
Use kill -l to see a list of all available signals on your system.