Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 9 Jul 2002 14:31:25 -0400 (EDT)
From:      Jerry McAllister <jerrymc@clunix.cl.msu.edu>
To:        effdefender@earthlink.net
Cc:        david@customfilmeffects.com (David Smithson), freebsd-questions@FreeBSD.ORG (FreeBSD-Questions)
Subject:   Re: How do I repeat a command N times?
Message-ID:  <200207091831.g69IVPp19888@clunix.cl.msu.edu>
In-Reply-To: <001001c2276c$bacddcc0$0301a8c0@sys.gtei.net> from "James" at Jul 09, 2002 10:19:06 AM

next in thread | previous in thread | raw e-mail | index | archive | help
> 
> I'm still new, but:
> It's probably your shell.
> The C-Shell (csh) isn't good for programming scripts.
> Try changing to the Bourne shell (sh) and running it again.
> Switch to the Bourne shell simply by typing "sh"

I don't understand that comment.  Most people I know switch FROM Bourne
to have easier script programming.  sh is used only because it is so
omni-present, even more than csh or tcsh or bash.

Of course, the syntax is different between sh and csh so you can't just
plop csh script in and interpret it as sh and vice versa.

> I think you might be able to program the C-Shell with C like statements, but
> I'm still learning.

Good.  Keep learning.

See below for useful version csh syntax.

Actually, usually I just use Perl.  It is so easy.
But, I hear it may not be available by default from now on.

////jerry

> 
> Hope this helps!
> -James Turnbull
> ----- Original Message -----
> From: "David Smithson" <david@customfilmeffects.com>
> To: "FreeBSD-Questions" <freebsd-questions@FreeBSD.ORG>
> Sent: Tuesday, July 09, 2002 10:13 AM
> Subject: Re: How do I repeat a command N times?
> 
> 
> > Wow!  So many options.
> >
> > Perl returns: "Badly placed ( "
> >
> > My shell is csh
> >
> > CSH returns "let: arith: syntax error: 'x=+1'" , yet continues and works.
> > What's with the error?

Well, I am guessing that here you want something like 

#!/bin/csh
# Note that 0 -> 606 is exactly 607 times unlike some of the 
# other examples given  (or use 1 -> 607 to be clear).

 @ fst = 0
 @ max = 606
while ($fst <= $max)
  echo Count is $fst
# Do whatever you need done here
  @ fst = $fst + 1
# alternatively you could increment as follows (minus the initial pound sign)
#   @ fst++
end


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?200207091831.g69IVPp19888>