Intermediate
Linux & Shell Scripting
Q45 / 100
What is the purpose of "trap" in bash scripting?
Correct! Well done.
Incorrect.
The correct answer is A) To capture and respond to signals or events (like EXIT, SIGINT, or ERR), allowing a script to run cleanup code before terminating
A
Correct Answer
To capture and respond to signals or events (like EXIT, SIGINT, or ERR), allowing a script to run cleanup code before terminating
Explanation
"trap 'cleanup_function' EXIT" registers a command to run when the script exits (normally or due to a signal), commonly used to clean up temporary files or release resources.
Progress
45/100