Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

RE: array as loopvariable - howto



> 
> 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