Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!psuvax1!rutgers!cmcl2!kramden.acf.nyu.edu!brnstnd From: brnstnd@kramden.acf.nyu.edu (Dan Bernstein) Newsgroups: comp.unix.shell Subject: Re: for loops Message-ID: <13418:Apr1203:39:4891@kramden.acf.nyu.edu> Date: 12 Apr 91 03:39:48 GMT References: <27850:Apr700:08:2591@kramden.acf.nyu.edu> <54239@mirror.tmc.com> <1991Apr10.212216.24238@amc.com> Organization: IR Lines: 22 In article <1991Apr10.212216.24238@amc.com> stuart@tfatf.amc.com (Stuart Poulin) writes: > In article <54239@mirror.tmc.com> kiyun@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