[GRASS-user] reverse output of g.mlist

Hamish hamish_b at yahoo.com
Sun Apr 10 07:31:43 EDT 2011


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



More information about the grass-user mailing list