trap
Execute a command upon an event. tldr-pages
On Linux
Several platforms
Linux
List the available event names (e.g. SIGWINCH)
trap -lIdentifyList the commands and the names of the expected events
trapIdentifyExecute a command when a signal is received
trap 'echo "Caught signal SIGHUP"' [1IdentifyRemove commands
trap - SIGHUP SIGINT ...IdentifyIgnore a signal
trap '' [2IdentifyExecute a command when the current shell exits
trap 'echo "Initiating cleanup"' EXITIdentifyExecute a command before every single command
trap 'echo "Debug output"' DEBUGIdentifyDisplay help
help trapIdentify