Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uflorida!haven!adm!news From: rbottin@atl.calstate.edu (Richard John Botting) Newsgroups: comp.unix.questions Subject: Re: Bourne Shell (/bin/sh) counting? Message-ID: <22788@adm.BRL.MIL> Date: 19 Mar 90 04:29:52 GMT Sender: news@adm.BRL.MIL Lines: 29 Jeff Asks > What is the best way to provide a loop counter in a Bourne > shell script? An example script is below, all it needs is > the count incrementer. > #!/bin/sh > count=0 [...] > # > echo count=$count Some people think that this answer is best thought of as a techie joke... count=`expr $count + 1` ^ ^ ^ ^ ^ The spaces a VERY significant, as are the reversed quotes. However it works and is useful in several of scripts. This is even funnier: count=` echo $count|awk '{print $1 + 1}'` I'd like to see a neat solution (other than a "increment.c" program). Dick Botting, Department of computer science, California State University, San Bernardino, CA 92407 rbottin@atl.calstate.edu >INTERNET:rbottin@atl.calstate.edu (Compuserve) paaaaar@calstate.bitnet voice:714-880-5327