## NAME

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

## KEYWORDS

general

## SYNOPSIS

g.findfile
g.findfile help
g.findfile element=string [mapset=string] file=string

### Parameters:

element=string
  Name of an element
mapset=string
  Name of a mapset
  Default:
file=string
  Name of an existing map

## DESCRIPTION

g.findfile is designed for Bourne shell scripts that need to search for raster map layer files, vector files, site list files, geographic region definition (windows) files, and imagery group files in the GRASS data base.

## OUTPUT

g.findfile writes four lines to standard output:

    name='file_name'
    mapset='mapset_name'
    file='unix_filename'
    fullname='grass_fullname'

The output is /bin/sh 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 /bin/sh as follows:

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

For example (raster map):

    eval `g.findfile element=cell file=mymap`

## NOTES

If the specified file 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
    fi

## SEE ALSO

g.ask
g.filename
g.gisenv
g.mapsets
parser

## AUTHOR

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

Last changed: $Date: 2006/05/16 13:45:49 $

Main index - general index - Full index