Hands-on task
A script with trap cleanup
Write /usr/local/bin/worktmp that creates a temporary file, does something with it, and is guaranteed to delete it on exit — even if the script is interrupted. After running, no temporary files should remain. Do the cleanup with trap. The script is easiest to write in the Editor tab above the terminal: /usr/local/bin is open there next to /root.
- trap
- mktemp
- signal handling
- EXIT
- resource cleanup