g.tempfile(1grass)

g.tempfile1grass

Creates a temporary file and prints it’s file name.

Usage

g.tempfile

g.tempfile --help

g.tempfile [-d] pid=integer [--help] [--verbose] [--quiet] [--ui]

Keywords

general, support, scripts

Overview

g.tempfile is designed for shell scripts that need to use large temporary files. GRASS provides a mechanism for temporary files that does not depend on /tmp/. GRASS temporary files are created in the data base with the assumption that there will be enough space under the data base for large files. GRASS periodically removes temporary files that have been left behind by programs that failed to remove them before terminating.

g.tempfile creates an unique file and prints the name. The user is required to provide a process-id which will be used as part of the name of the file. Most Unix shells provide a way to get the process id of the current shell. For /bin/sh and /bin/csh this is $$. It is recommended that $$ be specified as the process-id for g.tempfile.

Examples

For /bin/sh scripts the following syntax should be used:

temp1=`g.tempfile pid=$$`
temp2=`g.tempfile pid=$$`

For /bin/csh scripts, the following can be used:

set temp1=`g.tempfile pid=$$`
set temp2=`g.tempfile pid=$$`

Notes

Each call to g.tempfile creates a different (i.e. unique) name. Although GRASS does eventually get around to removing tempfiles that have been left behind, the programmer should make every effort to remove these files. They often get large and take up disk space. If you write /bin/sh scripts, learn to use the /bin/sh related trap command. If you write /bin/csh scripts, learn to use the /bin/csh related onintr command.

Source code

Available at: g.tempfile source code (history)

Accessed: Monday Feb 24 17:50:29 2025

Main index | General index | Topics index | Keywords index | Graphical index | Full index

© 2003-2025 GRASS Development Team, GRASS GIS 8.4.1 Reference Manual

Releases

10 releases since Debian 4.0 (Etch); the text changed 9 times.

  1. 4.0
  2. 5.0
  3. 6.0
  4. 7
  5. 8
  6. 9
  7. 10
  8. 11
  9. 12
  10. 13

Author

Michael Shapiro, U.S. Army Construction Engineering Research Laboratory

From grass-doc 8.4.1-1 in Debian 13 (Trixie). Parsed by carta from the page's man source.