Cleaning Up: trap and mktemp

mktemp makes a temporary file or folder with a name no other file has, and trap '...' EXIT runs cleanup however a script ends, Ctrl+C included, so a script that works in a scratch file never leaves half-finished work behind.

Updated

Cheat sheet for the lesson Cleaning Up: trap and mktemp: mktemp makes a temporary file or folder with a name no other file has, and trap '...' EXIT runs cleanup however a script ends, Ctrl+C included, so a script that works in a scratch file never leaves half-finished work behind.
Category
Bash
Level
Freelancer
Tags
linux, mktemp, signal, temporary-file, trap, unix