for loops

Dan Bernstein brnstnd at kramden.acf.nyu.edu
Sun Apr 7 10:08:25 AEST 1991


In article <rich.670890780 at pencil> rich at pencil.cs.missouri.edu (Rich Winkel) writes:
> 	for i in `head -$FILES /usr/dict/words`
> 		echo -n "*"
> 	done

  for i in `yes | head -$FILES`
    echo -n "*"
  done

But for this I'd probably just write

  yes '*' | head -$FILES | tr -d '
  '

And let's not forget the poor man's count script:

  #!/bin/sh
  ( echo $1 ; yes | head -$2 | sed 's/y/p1+/' ) | dc

$1 is the starting number, $2 how many numbers to produce. It even works
for floating-point---try count 3.14159 10.

---Dan



More information about the Comp.unix.shell mailing list