Skip to content

Instantly share code, notes, and snippets.

@mrWinston
Last active August 2, 2022 07:43
Show Gist options
  • Save mrWinston/0be99889d14cd1003411e8500d0f9103 to your computer and use it in GitHub Desktop.
Save mrWinston/0be99889d14cd1003411e8500d0f9103 to your computer and use it in GitHub Desktop.
Create and remove a temp file in a bash script
#!/bin/bash
tmpfile="$(mktemp)"
# Make sure the temp directory gets removed on script exit.
trap "exit 1" HUP INT PIPE QUIT TERM
trap rm -rf EXIT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment