[GRASSLIST:3800] Re: another scripting question

Hamish hamish_nospam at yahoo.com
Fri Jul 2 01:39:40 EDT 2004


> > I'm looking for a little more scripting advice as I put together a 
> > couple of tools to handle an  image rectifying job. I think I have
> > most of what I need, but I'm stuck on what I perceive as one of the
> > first steps.
> > 
> > Both scripts need to run through all files in a particular mapset.
> > 
> > Therefor my first question is how to step through each map within
> > the current mapset, so that the same procedure can be applied to
> > every one of them? Most of the examples I've found use the map name
> > as an argument specified on the command line.
> > 
> > Any tips?
> 
> 1. List the "cell" directory.
> 
> eval `g.gisenv`
> ls "$GISDBASE/$LOCATION_NAME/$MAPSET/cell" | while read map ; do
> 	... $map
> done



May I suggest g.mlist. It works very well these days (it was still a bit
broken in 5.0.3). Besides using wildcards for picking map names, it lets
you use regular expressions too if you want.


for MAP in `g.mlist rast` ; do
    echo "[$MAP]"
done



Hamish




More information about the grass-user mailing list