Bourne Shell (/bin/sh) counting?

Jeff Sullivan, x4096 MS 4-2 jsulliva at cvbnet.UUCP
Fri Mar 16 09:58:06 AEST 1990


  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

      for i in 1 2 3 4 5 6 7 8 9
      do
	# <increment count here>
	echo count=$count
      done

  I know there are other ways to accomplish the same thing,
  (such as the Korn shell), but I'd really like to know how
  to accomplish the above.

  Any help appreciated,
  -Jeff



More information about the Comp.unix.questions mailing list