g.findfile(1)
π g.findfile(1) β GRASS GIS User's Manual π
okay bestie, welcome to g.findfile, a lil legend from the GRASS GIS manual π it searches the GRASS data base for files and sets shell variables for you. no cap, it's giving "quietly doing the most important job in your script" energy π
β¨ NAME β¨
g.findfile β searches for GRASS data base files and sets variables for the shell π
πΈ KEYWORDS πΈ
general, map management, scripts
π SYNOPSIS π
g.findfile
g.findfile --help
g.findfile [-nl] element=string file=string [mapset=string] [--help]
[--verbose] [--quiet] [--ui]
π¦ Flags:
-nβ do not add quotes-lβ list available elements and dip out (exit), periodt--helpβ print usage summary--verboseβ verbose module output (chatty mode π£οΈ)--quietβ quiet module output (shy mode π€«)--uiβ force launching GUI dialog
π Parameters:
element=string[required] β name of an elementfile=string[required] β name of an existing mapmapset=stringβ name of a mapset (default: search path).'.'for current mapset
π DESCRIPTION π
g.findfile is literally designed for Bourne shell or Python scripts that need to search for mapset elements, including: raster, vector maps, region definitions and imagery groups. it's the bestie your script calls when it needs to know where things live π«Ά
the list of element names to search for is not fixed β any subdirectory of the mapset directory is a valid element name. so go off, name your subdirectories whatever, iykyk β¨
however!! the user can find the list of standard GRASS element names in the file $GISBASE/etc/element_list. this is the file which g.remove, g.rename and g.copy use to determine which files need to be deleted/renamed/copied for a given entity type. iconic behavior honestly π
π NOTES π
g.findfile writes four lines to standard output:
name='file_name'
mapset='mapset_name'
file='unix_filename'
fullname='grass_fullname'
the output is Bash commands to set the variable name to the GRASS data base file name, mapset to the mapset in which the file resides, and file to the full UNIX path name for the named file. these variables may be set in the Bash as follows:
eval `g.findfile element=name mapset=name file=name`
π«Ά lowkey the whole module is just "here's your variables, go be a main character"
π§ EXAMPLES π§
SHELL
raster map example:
eval `g.findfile element=cell file=elevation`
if the specified file (here: raster map) does not exist, the variables will be set as follows:
name=
mapset=
fullname=
file=
the following is a way to test for this case:
if [ ! "$file" ]
then
exit 1
fi
vector map example (including error message):
eval `g.findfile element=vector file="$G_OPT_V_INPUT"`
if [ ! "$file" ] ; then
g.message -e "Vector map <$G_OPT_V_INPUT> not found"
exit 1
fi
PYTHON
see Python Scripting Library for more info π
Note: the Python tab in the wxGUI can be used for entering the following code:
import grass.script as gcore
gcore.find_file(βelevationβ, element = βcellβ)
β SEE ALSO β
g.filename, g.gisenv, g.mapsets, g.parser
π AUTHOR π
Michael Shapiro, U.S.Army Construction Engineering Research Laboratory
π₯ SOURCE CODE π₯
available at: g.findfile source code (history)
accessed: Saturday Jan 17 05:40:39 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 bestie!! π this was GRASS 8.4.2, the g.findfile(1) manual, and yeah it's from the GRASS Development Team Β© 2003-2025, last touched Saturday Jan 17 05:40:39 2026 β slay, go set some variables β¨ππ¦
π¦ where this page comes from
- fedora 44: grass 8.4.2-4.fc44 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms