creating a script

I have a series raster files (cell files) located in /PERMANENT/cell. I want
to convert them into ASCII format using r.out.ascii command. I am trying to
write a script like a .sh command, but grass does not recognize it. Can anyone
tell me how I create a .sh program in grass.

You'll be better off using a foreach command, for example:

foreach i (`ls`)
? r.out.ascii $i > DIR/$i.asc
? end

The above would create ascii output of all files in the current directory.
(So preceeeding this, you would have made /PERMANENT/cell your current
working directory). If you want to test the effect before committing yourself,
substitute echo $i for the r.out.ascii line above. You can then see the list
that will be processed by the foreach. You may wish to use `ls xxx*` in
place of `ls` if you only want to transform some subset of the directory files.

Greg Koerper (greg@dubious.cor2.epa.gov) writes on 29 Dec 93:

I have a series raster files (cell files) located in /PERMANENT/cell. I want
to convert them into ASCII format using r.out.ascii command. I am trying to
write a script like a .sh command, but grass does not recognize it. Can anyone
tell me how I create a .sh program in grass.

                         ^^^^

You'll be better off using a foreach command, for example:

here is a minimal beginning:

#!/bin/sh
files=`g.list t=rast m=PERMANENT | egrep -v '^----' | egrep -v '^raster files'`
for i in $files; do
  echo processing $i
done

see the programming manual (chapter 25) and $GISBASE/scripts
for hints.

BTW, it sure would be a nice addition to the g.list command
if we could have a flag that would rid us of the extraneous
information that I had to grep out... or have I missed something.

--Darrell