Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 26 Oct 2001 13:37:38 -0700 (PDT)
From:      David Kirchner <davidk@accretivetg.com>
To:        The Almonds <cjalmond@yahoo.com>
Cc:        <freebsd-questions@FreeBSD.ORG>
Subject:   Re: Newbie-Simple C Shell programming help
Message-ID:  <20011026133427.A25870-100000@localhost>
In-Reply-To: <20011026163145.N731-100000@shumai.marcuscom.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 26 Oct 2001, The Almonds wrote:

> All,
>
> I am trying to run a program via a c shell 100 times
> for a stress test.
>
> I have
> #!/bin/sh
>
> for 1 in 1 2 3
>
> do
>
> x
>
> done
>
> as you can see this is painful if I want to do 100.
> Anyone know of a quick way to do this for 100 loops.

Others have pointed out the sh and csh way to do this, but I just thought
I'd also mention the "jot" program, which is pretty spiffy. You could then
do, in sh:

for i in `jot 100`
do
	whatever
done

If you wanted to do every other number (ie 0 2 4 6 8) you'd do:

for i in `jot 100 0 100 2`
do
	whatever
done

Check out man jot for details.


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20011026133427.A25870-100000>