create_temporary_directory.py
· 127 B · Python
Исходник
import tempfile, pathlib
with tempfile.TemporaryDirectory() as d:
tmp = pathlib.Path(d)
# tmp 下做所有中間產物
| 1 | import tempfile, pathlib |
| 2 | |
| 3 | with tempfile.TemporaryDirectory() as d: |
| 4 | tmp = pathlib.Path(d) |
| 5 | # tmp 下做所有中間產物 |
download_extract_cleanup.sh
· 140 B · Bash
Исходник
tmpdir="$(mktemp -d)"
trap 'rm -rf "$tmpdir"' EXIT
curl -fsSL "$URL" -o "$tmpdir/input.tar.gz"
tar -xzf "$tmpdir/input.tar.gz" -C "$tmpdir"
| 1 | tmpdir="$(mktemp -d)" |
| 2 | trap 'rm -rf "$tmpdir"' EXIT |
| 3 | curl -fsSL "$URL" -o "$tmpdir/input.tar.gz" |
| 4 | tar -xzf "$tmpdir/input.tar.gz" -C "$tmpdir" |
| 5 |