zsh-users
 help / color / mirror / code / Atom feed
From: Bruce Stephens <b.stephens@isode.com>
To: Sven Guckes <guckes@math.fu-berlin.de>
Cc: ZShell Users List <zsh-users@math.gatech.edu>
Subject: Re: counting in "for" loops
Date: 02 Dec 1998 16:50:42 +0000	[thread overview]
Message-ID: <vbd862trml.fsf@snake.isode.com> (raw)
In-Reply-To: Sven Guckes's message of "Wed, 2 Dec 1998 17:00:32 +0100"

Sven Guckes <guckes@math.fu-berlin.de> writes:

> Again, I look at the manual and  I cannot find
> how to do a simple count within a for loop.
> 
> 	$ for count in ???; do
> 	> echo -n $count
> 	> done
> 	1 2 3 4 5 6 7 8 9 10

This works for me (with zsh-3.1.4):

for ((count=1; count<=10; count++)); do
echo $count
done

> Why isn't this in the manual as an example?  *sigh*

The manuals don't have many examples, currently.  By all means
contribute things that you'd like to see in future versions, and this
example seems useful.  Although something like:

for ((count=0; count<10; count++))

would be a more common sort of requirement.

Alternatively {1..10} will expand to a list containing the numbers, so

for count in {1..10}; do
...

might be sufficient for what you want.  Doing the same for
{1..1000000} and things will take more memory than is optimal, though.


  parent reply	other threads:[~1998-12-02 16:57 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-12-02 16:00 Sven Guckes
1998-12-02 16:16 ` Thomas Koehler
1998-12-02 16:21   ` Peter Stephenson
1998-12-03  3:15     ` Updating documentation (Re: counting in "for" loops ) Timothy J Luoma
1998-12-02 16:50 ` Bruce Stephens [this message]
1998-12-03  4:22 ` counting in "for" loops Geoff Wing
1998-12-03 21:26   ` Phil Pennock
1998-12-03 21:27     ` Geoff Wing
1998-12-04 15:53     ` Phil Pennock

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=vbd862trml.fsf@snake.isode.com \
    --to=b.stephens@isode.com \
    --cc=guckes@math.fu-berlin.de \
    --cc=zsh-users@math.gatech.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).