trap - is used to execute a command when the shell receives any signal is called `trap`.

syntax
$ trap [options] "[arguments]" [signals]

To display the list of all commands associated with each condition
$ trap

To display the list of all signal names with number
$ trap -l

To Set `trap` command with signal number of SIGUP, SIGQUIT and SIGKILL
$ trap 'echo Trap command executed' 1 3 9
$ press Ctrl+C
$ ^CTrap command executed
$ trap

To Set trap command for ERR and EXIT
$ trap 'rm file.txt' err exit
$ trap



regards,
T.Dhanasekar