> For the complete documentation index, see [llms.txt](https://notes.davidfeng.us/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://notes.davidfeng.us/command-line-1/create-temp-files.md).

# Create temp files

```bash
#!/bin/bash

trap 'rm -f "$TMPFILE"' EXIT

TMPFILE=$(mktemp) || exit 1
echo "Our temp file is $TMPFILE"
```

Ref: <http://www.ruanyifeng.com/blog/2019/12/mktemp.html>

<https://wangdoc.com/bash/mktemp.html>
