Bourne shell question

Dan Gill dan at systech.bjorn.COM
Sun May 12 14:31:29 AEST 1991


In article <1991May8.192623.24160 at bnlux1.bnl.gov>, abrams at dan.ccd.bnl.gov (The Ancient Programmer) writes:
> 
> 	How does one do a simple computation in a shell script?
> The c-shell does it very neatly. 
> Running:
> 	#!/bin/csh
> 	set a = 10
> 	set b = 1
> 	@ c = $a - $b
> 	echo "a=$a, b=$b, c=$c"
> 
> produces: a=10, b=1, c=9
> 
you will have to do the math outside of the shell script with expr

try this:
a=10
b=1
c=`expr $a - $b`
echo "a=$a, b=$b, c=$c"

unless you don't have expr then you are back where you started...

Dg
-- 
-------------------------------------------------------------------------------
"On second thought, let us not go to Camelot.  It is a silly place"
Dan Gill                                          uunet!systech!dan
-------------------------------------------------------------------------------



More information about the Comp.unix.questions mailing list