Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: counting in "for" loops
- X-seq: zsh-users 1956
- From: mason@xxxxxxxxxxxxxxx (Geoff Wing)
- To: zsh-users@xxxxxxxxxxxxxxx
- Subject: Re: counting in "for" loops
- Date: 3 Dec 1998 04:22:57 GMT
- Organization: PrimeNet Computer Consultants
- References: <19981202170030.A2789@xxxxxxxxxxxxxxxxx>
- Reply-to: mason@xxxxxxxxxxxxxxx
Sven Guckes <guckes@xxxxxxxxxxxxxxxxx> 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@xxxxxxxxx> Mobile : 0412 162 441
Work URL: http://www.primenet.com.au/ Ego URL: http://pobox.com/~gcw/
Messages sorted by:
Reverse Date,
Date,
Thread,
Author