Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Problems with for loops
- X-seq: zsh-users 2904
- From: Oliver Kiddle <opk@xxxxxxxxxxxxx>
- To: Allen Belk <allen.belk@xxxxxxx>
- Subject: Re: Problems with for loops
- Date: Wed, 02 Feb 2000 19:09:47 +0000
- Cc: zsh-users@xxxxxxxxxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxxxxxxxxx; run by ezmlm
- References: <000501bf6dac$568a7420$3e525f83@xxxxxxxxxxx>
Allen Belk wrote:
>
> This is my test script:
>
> #!/bin/zsh
> ((i = 0))
> for (( i -eq 0; i -le 10; i++ )) do echo "$i\n" done
>
> When I execute this script, I get the following
>
> ./array_test.zsh: parse error near `(( i -eq 0' [3]
Try using:
for ((i=0;i<=10;i++)) do echo "$i\n"; done
See the section on Arithmetic Evaluation in the manual. Anything inside
(( ... )) is dealt with as a math expression so you use != == <= >= for
comparisons and = (and others like +=) for assignment. There is a full
list in the manual. You would use things like -eq and -le in a Condition
Expression (which is the following section of the manual). These are
introduced with [[ ... ]] and are more useful when doing operations on
strings, filenames etc.
Oliver Kiddle
> I know this is likely a newbie question but I have struggled with it for 3
> days. Any help will be greatly appreciated.
>
> Thank you,
>
> Allen Belk
>
> | Allen Belk, Systems Manager
> | Office of Technology Resources
> | University of Southern Mississippi
> | allen.belk@xxxxxxx 601.266.6013
Messages sorted by:
Reverse Date,
Date,
Thread,
Author