Introduction
Signal handling lets your script respond to events like pressing Ctrl+C. Using trap helps your script clean up or stop safely.
You want to stop a script safely when a user presses Ctrl+C.
You need to delete temporary files if the script is interrupted.
You want to run a command when the script exits for any reason.
You want to ignore certain signals to keep the script running.
You want to log a message when the script receives a specific signal.