g.filename(1grass)

โœจ g.filename โ€” the manual page, but make it cute โœจ

okay bestie, welcome to g.filename from the GRASS User's Manual (that's g.filename(1grass) if you're being formal, which likeโ€ฆ we are not ๐Ÿ’…). It prints GRASS data base file names. That's the whole job. She's simple, she's reliable, she's giving quiet competence. ๐ŸŽ€


๐ŸŒธ NAME ๐ŸŒธ

g.filename โ€” prints GRASS data base file names. literally that's it, that's her whole personality and we stan ๐Ÿซถ


๐Ÿฆ‹ KEYWORDS ๐Ÿฆ‹

general, map management, scripts

iykyk โ€” this is the scripts girlie. she exists to serve your shell scripts. ๐Ÿ‘‘


โœจ SYNOPSIS โœจ

g.filename
g.filename --help
g.filename [-c] element=string file=string  [mapset=string]   [--help]
[--verbose]  [--quiet]  [--ui]

๐ŸŽ€ Flags ๐ŸŽ€

  • -c โ€” Create element directory in the current mapset. If the element directory for the database file does not exist, create it. โœจ
  • --help โ€” Print usage summary. your lil bestie when you're lost ๐Ÿฅบ
  • --verbose โ€” Verbose module output. she talks more ๐Ÿ’ฌ
  • --quiet โ€” Quiet module output. she talks less ๐Ÿคซ
  • --ui โ€” Force launching GUI dialog. for the visual learners ๐Ÿ–ฅ๏ธ

๐Ÿ“ Parameters ๐Ÿ“

  • element=string [required] โ€” Name of an element. (yes. required. no skipping ๐Ÿ‘€)
  • file=string [required] โ€” Name of a database file. (also required, also no skipping)
  • mapset=string โ€” Name of a mapset (default: current). if you don't say, she assumes current ๐Ÿ’โ€โ™€๏ธ

๐Ÿ’– DESCRIPTION ๐Ÿ’–

g.filename is designed for Bourne shell scripts that need to know the full file name โ€” including its path โ€” for mapset elements. And bestie, "elements" here is a whole squad: raster, vector and site maps, region definitions, imagery groupsโ€ฆ the whole friend group. ๐ŸŒˆ

The list of element names to search for is not fixed. any subdirectory of the mapset directory is a valid element name. so like, she's not gatekeeping, she's flexible. ๐Ÿ’…

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/g.copy use to determine which files need to be deleted/renamed/copied for a given entity type. so it's kind of the โœจmain characterโœจ file for element lore. ๐Ÿ“œ


๐ŸŒŸ OUTPUT ๐ŸŒŸ

g.filename writes one line to standard output:

file='full_file_pathname'

The output is a /bin/sh command to set the variable specified by the file name to the full UNIX path name for the data base file. This variable may be set in the /bin/sh as follows:

eval `g.filename element=name mapset=name file=name`

yes it's a backtick eval. it's giving oldschool slay. do it exactly like that. ๐Ÿงš


๐Ÿ“ NOTES ๐Ÿ“

This module generates the filename, but does not care if the file (or mapset or element) exists or not. And honestly? that's the feature. This allows shell scripts to create new data base files as well as use existing ones. she's manifesting. ๐Ÿ”ฎ

If the mapset is the current mapset, g.filename can automatically create the element specified if it doesn't already exist when the -c flag is used. This makes it easy to add new files to the data base without having to worry about the existence of the required data base directories. ๐Ÿ‘‘

โš ๏ธ BUT. This program will not create a new mapset, however, if that specified does not currently exist. so don't come for her about mapsets, that is not her department ๐Ÿšซ

Also, this module should not be used to create directories which are at the level of what this module refers to as files, i.e., a directory which carries a name specified by a user (such as vector map directories) should not be created using this module. Standard library functions coming with any given language are a more appropriate tool for that. don't make her do a job that isn't hers, bestie, that's rude ๐Ÿ™ˆ

The program exits with a 0 if everything is ok; it exits with a non-zero value if there is an error, in which case file='full_file_pathname' is not output. so if you got nothing, check your exit status. ๐Ÿ’€


๐Ÿ‘€ SEE ALSO ๐Ÿ‘€

  • g.findfile
  • g.gisenv

go read those next, they're her friends ๐Ÿซถ


๐Ÿ’œ AUTHOR ๐Ÿ’œ

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

respect the OG ๐Ÿซก


๐ŸŒˆ SOURCE CODE ๐ŸŒˆ

Available at: g.filename source code (history)

Latest change: Friday Aug 08 09:39:19 2025 in commit: ed72c71d8580e872cd6fd345c84a15c324764465

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

ยฉ 2003-2026 GRASS Development Team, GRASS 8.5.0 Reference Manual


okay that's the whole page bestie, no cap, every flag and path exactly where it belongs ๐Ÿ’…

and for the lil sign-off: this was GRASS 8.5.0, from the 2003โ€“2026 GRASS Development Team era of the reference manual, footer and all โ€” she said g.filename(1grass), periodt. ๐Ÿ’–โœจ๐ŸŽ€

๐Ÿ“ฆ where this page comes from