[GRASS-user] g.mlist with logical operators?

Glynn Clements glynn at gclements.plus.com
Tue Feb 14 15:01:44 EST 2012


Johannes Radinger wrote:

> I'd like to list (using g.list) all raster maps
> that start with rast_* but not those which start with
> rast_A_* OR rast_B_* OR rast_C_*. I tried to use the
> OR operator and | but without success so far.
> Are such logical operators generally applicable with g.mlist?

No. You may be able to achieve what you want with regexps. Otherwise,
you can process the output from g.mlist with additional programs.

Writing a regexp which matches the union of multiple patterns
(A OR B OR C) is straightforward enough; just use "(A|B|C)" with
extended regexps or '\(A\|B\|C\)' with basic regexps (care needs to be
taken to ensure that backslashes are passed verbatim rather than being
interpreted by the shell). There isn't an equivalent operator for
intersection or difference, but you can achieve the same result by
filtering the output with "grep" or "grep -v" respectively.

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-user mailing list