painter@juniper.UUCP (Tom Painter ) (04/07/88)
I am having problems finding out how to do calculations in a shell script.
I am assuming there are methods because of the ability to check variables
using -lt, -gt, ... (<,>,etc). Granted this does not necessarily mean
that they do exist.
I would like to go through a loop 4 times,
The code roughly is :
if test "$cnt" -lt 5
do
msg$cnt= 'Message 1';;
#somehow increment cnt and go through loop again
cnt=cnt + 1
# ^^^^^^^^^^^ wrong language but message should be clear
done (etc......)
Thanks in advance
Tom
--
Tom Painter ut-emx!mybest!painter
or uunet!bigtex!mybest!painter morrell@hpsal2.HP.COM (Michael Morrell) (04/08/88)
#somehow increment cnt and go through loop again
cnt=cnt + 1
# ^^^^^^^^^^^ wrong language but message should be clear
Tom Painter ut-emx!mybest!painter
or uunet!bigtex!mybest!painter
----------
The proper syntax is to use expr:
cnt=`expr $cnt + 1`
Michael Morrellsue@encore.UUCP (Sue LoVerso) (04/08/88)
In article <2653@juniper.UUCP> painter@juniper.UUCP (Tom Painter ) writes: > >I am having problems finding out how to do calculations in a shell script. >#somehow increment cnt and go through loop again > cnt=cnt + 1 ># ^^^^^^^^^^^ wrong language but message should be clear cnt=`expr $cnt + 1` Man expr(1) for more details. -- Susan J. LoVerso Encore Computer Corp. sue@multimax.arpa encore!sue
karish@denali.UUCP (karish) (04/08/88)
In article <2653@juniper.UUCP> painter@juniper.UUCP (Tom Painter ) writes: > >I am having problems finding out how to do calculations in a shell script. >I would like to go through a loop 4 times, >The code roughly is : >if test "$cnt" -lt 5 > do > msg$cnt= 'Message 1';; > cnt=cnt + 1 ># ^^^^^^^^^^^ wrong language but message should be clear > > done (etc......) > cnt=`expr $cnt + 1`