# in your bash script TEMPFILE="`mktemp`" trap 'rm -f "$TEMPFILE"' EXIT echo "whatever" >$TEMPFILE # ...