Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: array as loopvariable - howto
- X-seq: zsh-users 6099
- From: "Bart Schaefer" <schaefer@xxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: array as loopvariable - howto
- Date: Sun, 11 May 2003 18:15:41 +0000
- In-reply-to: <20030508095814.1CFD6A717C@xxxxxxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20030508095814.1CFD6A717C@xxxxxxxxxxxxxxxxxxxxxxxxxx>
On May 8, 11:58am, jarausch@xxxxxxxxxxxxxxxxxxx wrote:
}
} for User in (User1,100) (User2,120); do echo "$U[1] has UID $U[2]";
} done
I've seen responses on how to do this with the new multi-variable "for"
syntax in 4.1, but nothing about how to do it in 4.0.
I'd say the obvious solution is an associative array.
4.1 multi-variable "for":
for user uid in User1 100 User2 120 ...; do echo $user has UID $uid; done
4.0 or 4.1 associative array:
typeset -A umap; umap=( User1 100 User2 120 ... )
for user in ${(k)umap}; do echo $user has UID $umap[$user]; done
Messages sorted by:
Reverse Date,
Date,
Thread,
Author