Register shell cleanup logic.
Section: Conditionals Loops and Functions
Run cleanup on exit
bash
bash
trap 'rm -f "$tmpfile"' EXITExplanation
Useful for temporary files, locks, and service teardown in scripts.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Conditionals Loops and Functions