|
|||
Department of Engineering | |
University of Cambridge > Engineering Department > computing help |
newfile=$(mktemp)If a script is prematurely aborted (the user may press
^C
for
example) it's good practise to remove any temporary files. The
trap command can be used to run a tidy-up routine when the
script (for whatever reason) exits. To see this in action start the following
script then press ^C
newfile=$(mktemp) trap "echo Removing $newfile ; rm -f $newfile" 0 sleep 100