I have this shell script:

r.mapcalc water = 120
d.rast water
while [ $i != 100 ]
    while [ $n != 10 ]
            r.mapcalc < water.mapcalc
            d.rast water
            n='expr $n + 1'
        g.copy rast=water,water.$i
        i = 'expr $i + 1'

It is from http://grass.osgeo.org/gdp/raster/mapcalc-algebra.pdf. I understand the syntax of the code since I am a programmer, but I cannot understand the line r.mapcalc < water.mapcalc. What does it mean? Sorry first time to use a shell script.


It's input redirection -- just like you can redirect the output of a command into a file,:

command > outfile.txt

you can redirect the input from a file:

command < infile.txt

This is the same as:

cat infile.txt | command

Hopefully helpful!

  • I do not know if I understood it correctly. Does it mean that the output of the water.mapcalc is "redirected" to the command r.mapcalc? But, what does the command r.mapcalc compute? Isn't it that the r.mapcalc command needs additional parameters in order to work (map name and value)? I'm trying to make the Hydrologic Simulation in grass.osgeo.org/gdp/raster/mapcalc-algebra.pdf work. Thanks – teamAngat Feb 21 '11 at 13:33
  • grass.fbk.eu/gdp/html_grass64/r.mapcalc.html should help. r.mapcalc is general purpose map algebra, and it will compute whatever the contents of the 'water.mapcalc' file tells it to compute. – Dan S. Feb 21 '11 at 21:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.