Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
RE: array as loopvariable - howto
- X-seq: zsh-users 6088
- From: Borzenkov Andrey <Andrey.Borzenkov@xxxxxxxxxxx>
- To: jarausch@xxxxxxxxxxxxxxxxxxx, zsh-users@xxxxxxxxxx
- Subject: RE: array as loopvariable - howto
- Date: Thu, 8 May 2003 14:24:23 +0400
- Importance: Normal
- In-reply-to: <20030508095814.1CFD6A717C@xxxxxxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
>
> I would like to write a loop over a list of arrays,
>
> e.g. I would like to iterate over pairs of (username,UID)
>
> A naiv try like
>
> for User in (User1,100) (User2,120); do echo "$U[1] has UID $U[2]";
> done
>
> failed.
> Is this possible in ZSH?
>
For array variables what is wrong with
A=(user1 uid1 ...)
B=(user2 uid2 ...)
for user uid in $A $B; do
echo User $user has $uid
done
for literal arrays just put them all in for loop
for user uid in user1 250 user2 350 ...
Or I do not understand your question?
-andrey
Messages sorted by:
Reverse Date,
Date,
Thread,
Author