1g.findfile(1)               GRASS GIS User's Manual              g.findfile(1)
2
3
4

NAME

6       g.findfile  - Searches for GRASS data base files and sets variables for
7       the shell.
8

KEYWORDS

10       general, map management, scripts
11

SYNOPSIS

13       g.findfile
14       g.findfile --help
15       g.findfile [-nl] element=string file=string  [mapset=string]   [--help]
16       [--verbose]  [--quiet]  [--ui]
17
18   Flags:
19       -n
20           Do not add quotes
21
22       -l
23           List available elements and exit
24
25       --help
26           Print usage summary
27
28       --verbose
29           Verbose module output
30
31       --quiet
32           Quiet module output
33
34       --ui
35           Force launching GUI dialog
36
37   Parameters:
38       element=string [required]
39           Name of an element
40
41       file=string [required]
42           Name of an existing map
43
44       mapset=string
45           Name of a mapset (default: search path)
46           ’.’ for current mapset
47

DESCRIPTION

49       g.findfile  is designed for Bourne shell or Python scripts that need to
50       search for mapset elements, including: raster, vector maps, region def‐
51       initions and imagery groups.
52
53       The  list of element names to search for is not fixed; any subdirectory
54       of the mapset directory is a valid element name.
55
56       However, the user can find the list of standard GRASS element names  in
57       the  file  $GISBASE/etc/element_list.  This is the file which g.remove,
58       g.rename and g.copy use to determine which files need to be deleted/re‐
59       named/copied for a given entity type.
60

NOTES

62       g.findfile writes four lines to standard output:
63       name=’file_name
64       mapset=’mapset_name
65       file=’unix_filename
66       fullname=’grass_fullname
67       The  output is Bash commands to set the variable name to the GRASS data
68       base file name, mapset to the mapset in which  the  file  resides,  and
69       file to the full UNIX path name for the named file. These variables may
70       be set in the Bash as follows:
71       eval `g.findfile element=name mapset=name file=name`
72

EXAMPLES

74   SHELL
75       Raster map example:
76       eval `g.findfile element=cell file=elevation`
77       If the specified file (here: raster map) does not exist, the  variables
78       will be set as follows:
79       name=
80       mapset=
81       fullname=
82       file=
83       The following is a way to test for this case:
84       if [ ! "$file" ]
85       then
86            exit 1
87       fi
88
89       Vector map example (including error message):
90       eval `g.findfile element=vector file="$G_OPT_V_INPUT"`
91       if [ ! "$file" ] ; then
92          g.message -e "Vector map <$G_OPT_V_INPUT> not found"
93          exit 1
94       fi
95
96   PYTHON
97       See Python Scripting Library for more info.
98
99       Note:  The Python tab in the wxGUI can be used for entering the follow‐
100       ing code:
101
102       import grass.script as gcore
103       gcore.find_file(’elevation’, element = ’cell’)
104

SEE ALSO

106        g.filename, g.gisenv, g.mapsets, g.parser
107

AUTHOR

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

SOURCE CODE

112       Available at: g.findfile source code (history)
113
114       Accessed: Saturday Jan 21 20:38:12 2023
115
116       Main index | General index | Topics index | Keywords index |  Graphical
117       index | Full index
118
119       © 2003-2023 GRASS Development Team, GRASS GIS 8.2.1 Reference Manual
120
121
122
123GRASS 8.2.1                                                      g.findfile(1)
Impressum