From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29967 invoked by alias); 9 Jun 2014 10:06:25 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 18889 Received: (qmail 4300 invoked from network); 9 Jun 2014 10:06:11 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.2 X-Injected-Via-Gmane: http://gmane.org/ To: zsh-users@zsh.org From: Thorsten Kampe Subject: Iterating over a set of arrays Date: Mon, 9 Jun 2014 12:05:51 +0200 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: p5de5aec0.dip0.t-ipconnect.de User-Agent: MicroPlanet-Gravity/3.0.4 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