[GRASS-user] wildcards and/or regular expressions: bash vs. grass' cli

Nikos Alexandris nikos.alexandris at felis.uni-freiburg.de
Fri Aug 7 04:49:24 EDT 2009


Hi list. I don't understand the following:

while the command

---
# outside of grass' shell
"ls -l MOD09GA_????_!(203)_*_sur_refl_b01"
---

works fine under (normal) bash (version 3.2.48(1)) [1], the same search
pattern fails to give results when used with g.mlist and returns an
error. E.g.,

---
# from within grass' shell
"g.mlist pat=MOD09GA_????_!(203)_500m_sur_refl_b0?"
bash: !: event not found
---

The same error is returned even when I use "-r", "-e" switches with
g.mlist, as well as when I define the string within double quotes [2].
The command does not return anything if the string is placed in single
ticks (')[3].

However, escaping the parentheses works under grass but not under bash.
e.g.:

---
# from within grass' shell
g.mlist pat=MOD09GA_2007_\(203\)*_sur_refl_b01
MOD09GA_2007_203_500m_sur_refl_b01
---
# outside of grass' shell
ls MOD09GA_2007_\(203\)*_sur_refl_b01
ls: cannot access MOD09GA_2007_(203)*_sur_refl_b01: No such file or
directory
---

In addition, the string "MOD09GA_????_{203}_*_sur_refl_b01" (using curly
braces) works under grass but _not_ under bash.

There is the "exclude" parameter for g.mlist which finally does what I
want to do. Yet, I would like to know what is the explanation for this
behaviour?

I've been through the manuals [M1][M2] but I have no idea where to trace
this down. Is it that I don't understand the regular/ extended
expressions [4] or is it something special/different to grass?

Kind regards, Nikos
---

[1] ls MOD09GA_????_!(203)_*_sur_refl_b01
MOD09GA_2007_202_500m_sur_refl_b01  MOD09GA_2007_208_500m_sur_refl_b01
MOD09GA_2008_205_500m_sur_refl_b01  ...

[2] both of the following return the same error
g.mlist pat="MOD09GA_????_!(203)_*_sur_refl_b01" -r
g.mlist pat="MOD09GA_????_!(203)_*_sur_refl_b01" -e
bash: !: event not found

[3] using simple ticks: no error message but no result either
g.mlist pat='MOD09GA_????_!(203)_*_sur_refl_b01' -e
g.mlist pat='MOD09GA_????_!(203)_*_sur_refl_b01' -r

[4] http://en.wikipedia.org/wiki/Regular_expression
[M1]
http://grass.osgeo.org/grass64/manuals/html64_user/variables.html#enviro
[M2] http://grass.osgeo.org/grass64/manuals/html64_user/g.mlist.html




More information about the grass-user mailing list