[GRASS-user] reverse output of g.mlist

Dear list,

if have some Landsat 7 sets that I want to patch together to fill up the
gaps. To get things a little faster, I wanted to pipe the output of g.mlist
to r.patch so that I do not need to type in everything by hand. My problem
now ist, that g.mlist prints the raster-maps in alphabetical/numeric order.
As the cloud cover is lowest for the (numerical) last raster map, I'd like
to reverse the output of g.mlist so that the last map will be on top of the
r.patch process. I tried as follows:

The standard output of my g.mlist-pattern is as follows:
~ > g.mlist type=rast sep=, pat="*B10"
129_04720110101_B10,129_04720110117_B10,129_04720110306_B10

My aim is to reverse the output as follows
129_04720110306_B10,129_04720110117_B10,129_04720110101_B10

which I tried with:
g.mlist type=rast sep=, pat="*B10"|sort -r

But the output remains as:
129_04720110101_B10,129_04720110117_B10,129_04720110306_B10

Any ideas about what I am doing wrong here?

--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/reverse-output-of-g-mlist-tp6258459p6258459.html
Sent from the Grass - Users mailing list archive at Nabble.com.

Stefan wrote:

if have some Landsat 7 sets that I want to patch together
to fill up the gaps. To get things a little faster, I wanted to
pipe the output of g.mlist to r.patch so that I do not need to
type in everything by hand. My problem now ist, that g.mlist
prints the raster-maps in alphabetical/numeric order.
As the cloud cover is lowest for the (numerical) last
raster map, I'd like to reverse the output of g.mlist so that
the last map will be on top of the r.patch process. I tried as
follows:

The standard output of my g.mlist-pattern is as follows:
~ > g.mlist type=rast sep=, pat="*B10"
129_04720110101_B10,129_04720110117_B10,129_04720110306_B10

My aim is to reverse the output as follows
129_04720110306_B10,129_04720110117_B10,129_04720110101_B10

which I tried with:
g.mlist type=rast sep=, pat="*B10"|sort -r

But the output remains as:
129_04720110101_B10,129_04720110117_B10,129_04720110306_B10

you're very close. `sort` goes by lines, so output with newline
as the field separator, tac, and then trade newlines for commas:

g.mlist type=rast pat="*B10" | sort -r | tr '\n' ','

Hamish

Ok, now it works properly! Thanks for all your help.

Here just to show how I finally did it:

r.patch -z in=`g.mlist type=rast pat="*B10" | sort -r | tr '\n' ','`
out=129_047_b10_patch

Stefan

--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/reverse-output-of-g-mlist-tp6258459p6258841.html
Sent from the Grass - Users mailing list archive at Nabble.com.