trap
trap runs code on signals or when the script exits.
Example
cleanup() { echo "cleaning"; }
trap cleanup EXIT
echo "working"
exit 0Result
working cleaning
Exercise
Run at exit.
trap f Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.