Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!samsung!uunet!osh3!chip From: chip@osh3.OSHA.GOV (Chip Yamasaki) Newsgroups: comp.unix.questions Subject: Re: Bourne shell question Message-ID: <1991May10.013943.2325@osh3.OSHA.GOV> Date: 10 May 91 01:39:43 GMT References: <1991May8.192623.24160@bnlux1.bnl.gov> Organization: U.S. D.O.L - Occupational Safety & Health Admin. Lines: 27 In <1991May8.192623.24160@bnlux1.bnl.gov> abrams@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 >but I've been unable to find out how to do this in the bourne shell. You don't, exactly. What you do is use the expr program. It is slower because it is external, but it works just fine. Try #!/bin/sh a=10 b=1 c=`expr $a + $b` echo "a=$a b=$b c=$c" -- -- Charles "Chip" Yamasaki chip@oshcomm.osha.gov