zsh-users
 help / color / mirror / code / Atom feed
From: mason@primenet.com.au (Geoff Wing)
To: zsh-users@math.gatech.edu
Subject: Re: counting in "for" loops
Date: 3 Dec 1998 04:22:57 GMT	[thread overview]
Message-ID: <slrn76c4h1.9s2.mason@coral.primenet.com.au> (raw)
In-Reply-To: <19981202170030.A2789@math.fu-berlin.de>

Sven Guckes <guckes@math.fu-berlin.de> typed:
: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
:What do I need for "???"?
:Why isn't this in the manual as an example?  *sigh*

The manual does list quite a few methods if you read it above and below
the section on for loops.  Most people would have found a method they
like and use it.  It's not as if there aren't a few choices.  For starters:

% count=1; while ( [[ $count -le 10 ]] ); do echo -n $count; let count++; done
% count=1; while ( [[ $count -le 10 ]] ); do echo -n $count; (( count++ )); done
% count=1; while ( [[ count -le 10 ]] ); do echo -n $count; let count++; done
% count=1; while ( [[ count -le 10 ]] ); do echo -n $count; (( count++ )); done
% count=1; while ( [[ $count -le 10 ]] ) { echo -n $count; let count++ }
% count=1; while ( [[ $count -le 10 ]] ) { echo -n $count; (( count++ )) }
% count=1; while ( [[ count -le 10 ]] ) { echo -n $count; let count++ }
% count=1; until ( [[ $count -gt 10 ]] ) { echo -n $count; (( count++ )) }
% count=1; until ( [[ count -gt 10 ]] ); do echo -n $count; let count++; done
% count=1; until ( [[ $count -gt 10 ]] ); do echo -n $count; (( count++ )); done
% count=1; until ( [[ count -gt 10 ]] ) { echo -n $count; let count++ }
% count=1; until ( [[ count -gt 10 ]] ) { echo -n $count; (( count++ )) }
% count=1; repeat 10; do echo -n $count; let count++; done
% count=1; repeat 10; do echo -n $count; (( count++ )); done
% count=1; repeat 10 { echo -n $count; let count++ }
% count=1; repeat 10 { echo -n $count; (( count++ )) }
% for count in {1..10}; do echo -n $count; done
% for count in {1..10}; echo -n $count
zsh-3.1.5% for (( count=1; count <= 10; count++ )); do echo -n $count; done
zsh-3.1.5% for ((count=1; count<=10; count++)) echo -n $count

-- 
Geoff Wing   <gcw@pobox.com>            Mobile : 0412 162 441
Work URL: http://www.primenet.com.au/   Ego URL: http://pobox.com/~gcw/


  parent reply	other threads:[~1998-12-03  4:29 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 ` counting in "for" loops Bruce Stephens
1998-12-03  4:22 ` Geoff Wing [this message]
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=slrn76c4h1.9s2.mason@coral.primenet.com.au \
    --to=mason@primenet.com.au \
    --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).