Skip to content

g.remove

Removes data base element files from the user's current mapset using the search pattern.

g.remove [-irefb] type=datatype [,datatype,...] [name=string [,string,...]] [ignore=string [,string,...]] [pattern=string] [exclude=string] [--verbose] [--quiet] [--qq] [--ui]

Example:

g.remove type=datatype pattern=string

grass.script.run_command("g.remove", type, name=None, ignore=None, pattern=None, exclude=None, flags=None, verbose=False, quiet=False, superquiet=False)

Example:

gs.run_command("g.remove", type="datatype", pattern="string")

Parameters

type=datatype [,datatype,...] [required]
    Data type(s)
    Allowed values: raster, raster_3d, vector, label, region, group, all
    raster: raster map(s)
    raster_3d: 3D raster map(s)
    vector: vector map(s)
    label: paint label file(s)
    region: region definition(s)
    group: imagery group(s)
    all: all types
name=string [,string,...]
    Name of file(s) to remove
ignore=string [,string,...]
    Name of file(s) to ignore (default: none)
pattern=string
    File name search pattern
exclude=string
    File name exclusion pattern (default: none)
-i
    Ignore case
-r
    Use basic regular expressions instead of wildcards
-e
    Use extended regular expressions instead of wildcards
-f
    Force removal (required for actual deletion of files)
-b
    Remove base raster maps
--help
    Print usage summary
--verbose
    Verbose module output
--quiet
    Quiet module output
--qq
    Very quiet module output
--ui
    Force launching GUI dialog

type : str | list[str], required
    Data type(s)
    Used as: datatype
    Allowed values: raster, raster_3d, vector, label, region, group, all
    raster: raster map(s)
    raster_3d: 3D raster map(s)
    vector: vector map(s)
    label: paint label file(s)
    region: region definition(s)
    group: imagery group(s)
    all: all types
name : str | list[str], optional
    Name of file(s) to remove
    Used as: input, element
ignore : str | list[str], optional
    Name of file(s) to ignore (default: none)
    Used as: input, element
pattern : str, optional
    File name search pattern
exclude : str, optional
    File name exclusion pattern (default: none)
flags : str, optional
    Allowed values: i, r, e, f, b
    i
        Ignore case
    r
        Use basic regular expressions instead of wildcards
    e
        Use extended regular expressions instead of wildcards
    f
        Force removal (required for actual deletion of files)
    b
        Remove base raster maps
verbose: bool, optional
    Verbose module output
    Default: False
quiet: bool, optional
    Quiet module output
    Default: False
superquiet: bool, optional
    Very quiet module output
    Default: False

DESCRIPTION

g.remove removes data files matching a pattern given by wildcards or POSIX Extended Regular Expressions. If the -f force flag is not given then nothing is removed, instead the list of selected file names is printed to stdout as a preview of the files to be deleted.

EXAMPLES

Delete map1 and map2 raster maps in the current mapset:

g.remove -f type=raster name=tmp1,tmp2

Delete all raster and vector maps starting with "tmp_" in the current mapset:

# show matching raster and vector maps but do not delete yet (as verification)
g.remove type=raster,vector pattern="tmp_*"

# actually delete the matching raster and vector maps
g.remove -f type=raster,vector pattern="tmp_*"

Delete all vector maps starting with "stream_" in the current mapset, but exclude those ending with "_final":

g.remove -f type=vector pattern="stream_*" exclude="*_final"

AUTHOR

Huidae Cho
grass4u@gmail.com

SOURCE CODE

Available at: g.remove source code (history)
Latest change: Tuesday Apr 01 23:35:19 2025 in commit 79b2bc9