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

Hi,

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?

Best regards,

Johannes
--
NEU: FreePhone 3-fach-Flat mit kostenlosem Smartphone!
Jetzt informieren: http://www.gmx.net/de/go/freephone/

On Tue, Feb 14, 2012 at 3:28 PM, Johannes Radinger <JRadinger@gmx.at> wrote:

Hi,

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?

Probably yes. I suppose that you need to enable one of these:
-r
    Use basic regular expressions instead of wildcards
-e
    Use extended regular expressions instead of wildcards

Markus

Johannes 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?

yes, the the basic or extended regex flags you can do pretty much any
pattern matching you can think of.

try like rast_[^A-C][^_]

see http://www.regular-expressions.info/
(it is well worth anyone's time to spend a few hours learning a bit of
regex, the payback in saved time is enormous)

Hamish

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@gclements.plus.com>

Thank you all,

I'll have a look into regular expressions... sound very promissing
to me.

/johannes

-------- Original-Nachricht --------

Datum: Tue, 14 Feb 2012 20:01:44 +0000
Von: Glynn Clements <glynn@gclements.plus.com>
An: "Johannes Radinger" <JRadinger@gmx.at>
CC: GraSS user list <grass-user@lists.osgeo.org>
Betreff: Re: [GRASS-user] g.mlist with logical operators?

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@gclements.plus.com>

--
NEU: FreePhone 3-fach-Flat mit kostenlosem Smartphone!
Jetzt informieren: http://www.gmx.net/de/go/freephone/