[GRASS5] $GIS_OPT = "(null)" to "" in scripts

Glynn Clements glynn at gclements.plus.com
Wed Jan 19 13:47:49 EST 2005


Hamish wrote:

> > scripts/i.oif/i.oifcalc
> 
> could someone test that one? There is this sort of thing:
> 
> awk '{print sum > "$temp_file"}'
> 
> which I am pretty sure will break but don't know enough awk to fix.

If you want to use shell variables in awk commands, the easiest way is
probably to define a corresponding awk variable, e.g.

	awk -v temp_file="$temp_file" ...

then use:

	print sum > temp_file

within awk.

The alternative is to wrap the awk commands in double quotes, so that
shell variables are substituted.

That's fine for trivial commands, but for more complex commands you
typically end up with undesired substitions (e.g. $1 will be replaced
with the script's first argument, which probably isn't what you want).

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-dev mailing list