Ravindra BagaleCourses & study guides मराठी Track your progress

Ravi Sir's Cards › AWS

AWS Cloud

trap cleanup

This revision card explains trap cleanup. It starts from the need that make a temp folder. It describes clean on any exit. The how-to section notes catch Ctrl+C. An example on the card is report errors.

trap cleanup Make a temp folder. Clean on any exit. Catch Ctrl+C. Report errors.
trap cleanup · Download PNG
Read card text

What this card says

Why do we need it?

Make a temp folder.

tmp=$(mktemp -d)

What is it?

Clean on any exit.

trap 'rm -rf "$tmp"' EXIT

How to do it

Catch Ctrl+C.

trap 'exit 130' INT

Example

Report errors.

trap 'echo line $LINENO' ERR

See all AWS revision cards