temporary file
A file or directory a script creates for its own scratch work and should delete before it finishes.
In more detail
Temporary files hold intermediate results that are too big for memory or must be handed between steps. Create them with a tool or library function that gives unique, safe names, such as mktemp in the shell, and remove them when the work is done, even if it fails. Predictable names in a shared directory such as /tmp can let another user read or replace your data.
Example
External sorting writes each sorted chunk to a temporary file; Python's tempfile module creates them.Related terms
- external sort — Sorting data too large to fit in memory by sorting it in memory-sized chunks written to disk, then merging the sorted chunks.
- mktemp — The command that safely creates a new, uniquely named temporary file, or with -d a directory, and prints its path.
- EXIT trap — A trap on the special name EXIT, whose handler runs whenever the shell exits: at the end, on exit, or when set -e stops it.
Taught in
- Sorting In Real Systems: Stability, Keys And External Sort — Algorithms & Data Structures for Working Engineers
- Moving Around: pwd, ls, cd And Paths — Bash Scripting & Command Line Automation
- What Bash Does To A Line Before It Runs It — Bash Scripting & Command Line Automation
- Redirection: Truncate, Append, Both Streams — Bash Scripting & Command Line Automation
- Pipelines, tee And Process Substitution — Bash Scripting & Command Line Automation
- Command Substitution And Subshells — Bash Scripting & Command Line Automation
- Script Input And Output: read, Heredocs, printf — Bash Scripting & Command Line Automation
- trap, Cleanup And Temporary Files — Bash Scripting & Command Line Automation
- Processes, Jobs And Signals — Bash Scripting & Command Line Automation
- Scheduling, Monitoring And A Script That Reports — Bash Scripting & Command Line Automation