一時ファイルの一掃
"clean up temporary files"から拝借。
#! bash # # 終了時処理 # http://www.linuxjournal.com/content/use-bash-trap-statement-cleanup-temporary-files # declare -a on_exit_items function on_exit { for i in "${on_exit_items[@]}" do eval $i done } function add_exit_item { local n=${#on_exit_items[*]} on_exit_items[$n]="$*" } trap on_exit EXIT tmppath1=`mktemp` tmppath2=`mktemp` add_exit_item rm -f "\"$tmppath1\"" add_exit_item rm -f "\"$tmppath2\""