From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2238 invoked from network); 2 Dec 1998 16:57:11 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 2 Dec 1998 16:57:11 -0000 Received: (from list@localhost) by math.gatech.edu (8.9.1/8.9.1) id LAA19104; Wed, 2 Dec 1998 11:52:33 -0500 (EST) Resent-Date: Wed, 2 Dec 1998 11:52:28 -0500 (EST) Sender: B.Stephens@isode.com To: Sven Guckes Cc: ZShell Users List Subject: Re: counting in "for" loops References: <19981202170030.A2789@math.fu-berlin.de> Mime-Version: 1.0 (generated by tm-edit 7.108) Content-Type: text/plain; charset=US-ASCII From: Bruce Stephens Date: 02 Dec 1998 16:50:42 +0000 In-Reply-To: Sven Guckes's message of "Wed, 2 Dec 1998 17:00:32 +0100" Message-ID: X-Mailer: Gnus v5.6.27/XEmacs 20.4 - "Emerald" Resent-Message-ID: <"K7dDK2.0.pf4.B1NPs"@math> Resent-From: zsh-users@math.gatech.edu X-Mailing-List: archive/latest/1954 X-Loop: zsh-users@math.gatech.edu X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu Sven Guckes 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.