g.tempfile(1)

✨ g.tempfile ✨

okay bestie, so this is a page from the GRASS GIS User's Manual β€” it's g.tempfile(1) and it's giving "tiny utility, huge main character energy". let's get into it πŸ’…

🌸 NAME 🌸

g.tempfile β€” creates a temporary file and prints it's file name. yes, that's the actual wording, the apostrophe crimes are canon, don't come for me 🫢

πŸŽ€ KEYWORDS πŸŽ€

general, support, scripts


πŸ¦‹ SYNOPSIS πŸ¦‹

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

✨ Flags ✨

  • -d β€” dry run!! literally don't create a file, just prints it's file name. manifesting the filename without the file, iconic πŸ™ˆ
  • --help β€” print usage summary
  • --verbose β€” verbose module output (chatty mode fr fr)
  • --quiet β€” quiet module output
  • --ui β€” force launching GUI dialog

πŸ“ Parameters πŸ“

  • pid=integer [required] β€” process id to use when naming the tempfile. yes REQUIRED. no pid, no tempfile, no service πŸ’€

πŸ’– DESCRIPTION πŸ’–

so 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. and like, GRASS periodically removes temporary files that have been left behind by programs that failed to remove them before terminating β€” so it's not a total free-for-all, the cleanup girlies do come through eventually ✨

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.

lowkey the whole vibe here is: you give it a pid, it gives you a name. that's the deal. that's the friendship. 🀝

🌈 EXAMPLE 🌈

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. no cap, every single call, fresh name, every time πŸŽ€

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.

bestie PLEASE clean up after yourself. these files get big, they eat disk space, and "GRASS will get around to it" is not a chore chart. learn trap for /bin/sh, learn onintr for /bin/csh. that's the assignment πŸ’…

πŸ’œ AUTHOR πŸ’œ

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


⭐ SOURCE CODE ⭐

Available at: g.tempfile source code (history)

Accessed: Saturday Jan 17 05:40:40 2026

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

Β© 2003-2025 GRASS Development Team, GRASS GIS 8.4.2 Reference Manual


and that's the whole page babes 🫢 this was GRASS 8.4.2, rendered for you as g.tempfile(1) β€” go make a tempfile, and for the love of everything, delete it when you're done πŸ’–βœ¨

πŸ“¦ where this page comes from