Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!systech!dan From: dan@systech.bjorn.COM (Dan Gill) Newsgroups: comp.unix.questions Subject: Re: Bourne shell question Summary: try expr Message-ID: <907@systech.bjorn.COM> Date: 12 May 91 04:31:29 GMT References: <1991May8.192623.24160@bnlux1.bnl.gov> Organization: Systech Corp., San Diego, CA Lines: 29 In article <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 > 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 -------------------------------------------------------------------------------