for loops

Dan Bernstein brnstnd at kramden.acf.nyu.edu
Fri Apr 12 13:39:48 AEST 1991


In article <1991Apr10.212216.24238 at amc.com> stuart at tfatf.amc.com (Stuart Poulin) writes:
> In article <54239 at mirror.tmc.com> kiyun at mirror.UUCP (KiYun Roe) writes:
> >I like this!  I've been looking for a simple way to do this.  I didn't
> >realize that there was a command like yes.  Is it BSD, System V, or
> >both?

I believe it appeared in v7, but I'm not sure how portable the argument
is.

> Hey! cool idea.  How about using bc and adding a step argument:

No need for bc. Step can be positive or negative here.

#!/bin/sh
# pmcount start [ num [ step ] ], num default 10, step default 1
step=`echo ${3-1} | sed 's/-/_/g'`
( echo $1 ; yes | head -${2-10} | sed 's/y/p'$step'+/' ) | dc

I suppose the yes and head could be replaced by echo and a more complex
sed script.

---Dan



More information about the Comp.unix.shell mailing list