Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Iterating over a set of arrays
- X-seq: zsh-users 18889
- From: Thorsten Kampe <thorsten@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Iterating over a set of arrays
- Date: Mon, 9 Jun 2014 12:05:51 +0200
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
Hi,
this is originally a bash question but I'd also be interested in a
zsh solution (or if there is no solution).
I'd like to get the second element of a set of arrays.
arrayA=(a1 a2 a3)
arrayB=(b1 b2 b3)
arrayC=(c1 c2 c3)
The output should be
a2
b2
c2
To avoid repetitive code, I'd like to do this in a loop.
The below does not work because iterating over an array iterates over
the elements and there is no array of arrays in bash and zsh
for array in ${arrayA[@]} ${arrayB[@]}
do
echo ${array[1]}
done
So is there a solution to the above problem?
Thorsten
Messages sorted by:
Reverse Date,
Date,
Thread,
Author