From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8090 invoked by alias); 25 Jun 2017 12:44:43 -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: 22749 Received: (qmail 5637 invoked from network); 25 Jun 2017 12:44:43 -0000 X-Qmail-Scanner-Diagnostics: from mail-wr0-f182.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(209.85.128.182):SA:0(-2.8/5.0):. Processed in 0.533833 secs); 25 Jun 2017 12:44:43 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_PASS,T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: agross@therightstuff.de X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.128.182 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=therightstuff.de; s=google; h=mime-version:from:date:message-id:subject:to; bh=IZht51imr9eNI7fPHjBUTzLeEc6IpuHYB6rFKrhQm7I=; b=ejVYd8a2euR8xZnBTSMYGLLwRiZEWXmHFXwJur7PNrzUfl/YwGk5fmngO2bxu6NfDt OwoCV+ZoxFWcScL7zdEDd/EoQxslkZlKmfjbXwWNCPHwmzS7Rm99CF+iIyq5LmeI3ayM z0mTOuEakMhP2NV5JB2S0KUoOhbK7YbYykd3w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=IZht51imr9eNI7fPHjBUTzLeEc6IpuHYB6rFKrhQm7I=; b=XYPFc2kmrY/WqTySg1BEcx7ikgzycXfxqrKCUDzJA8RX5FPIc6d158H78H1Tl3NT0H gX2PHUm4m+lGn3sjcKWlItvHqMFzzR9nVIr581/a+B4YE6A+cMqmf9vx9bw7d/zHiXKr Vm/0X7+gVQxG3C2PwWbF7b+HRA2xuc/dEHVzN0nIaFZGTxAHjQ5CMjS9qGbOjWB8Rqdr afJyrI3PZrPu/0lZERm7+K4cUfiXUy+u99ovKJ/2PI4eFWi2FB4UznxdguWjx5S7a59e 0PZ03Keg8xw6jaaNwxurLKAh1LEHn8C1kYsu6QMrwnF/Z75n1xk9xt9LpOjzNtpRZEdy IFIg== X-Gm-Message-State: AKS2vOzca1Lc/hanqc6NCeVUyA1aUVFdN5TGhVFE1rsHlb2tc8gX727A ScmiTlExcnkCuy319I9cMrlUlyEwmhxzR0GW5g== X-Received: by 10.28.128.67 with SMTP id b64mr10274330wmd.79.1498394677970; Sun, 25 Jun 2017 05:44:37 -0700 (PDT) MIME-Version: 1.0 X-Originating-IP: [2001:470:1f0b:c9a:a974:46a2:b306:7a10] From: =?UTF-8?Q?Alexander_Gro=C3=9F?= Date: Sun, 25 Jun 2017 14:44:17 +0200 Message-ID: Subject: Array parameter expansion: take n-th word from array elements To: zsh-users@zsh.org Content-Type: multipart/alternative; boundary="001a114184fa83aeae0552c83250" --001a114184fa83aeae0552c83250 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi all, I would like to parse some output from a command that generates an array of the following elements: Main System.Xml.XPath - 4.3 Main System.Xml.XPath.XDocument - 4.3 Test Castle.Core - 4.0 Test FsCheck - 2.9 E.g. foo=3D('a interesting - b' 'a also-interesting - c') I would like to take the second word from each and every of the array elements (interesting also-interesting). Unfortunately, print -l ${foo[2]} prints the second element, 'a also-interesting - c'. A for loop works: local -a filtered for package in $foo; do # Split by space and take second word. filtered+=3D"${${(s. .)package}[2]}" done But I wonder if there is a better way using parameter expansion. Here's what I came up with so far: print -l ${${(s. .)foo}[2]} Unfortunately, it just prints 'interesting'. Any ideas pointing me in the right direction are greatly appreciated! Alex --=20 Alexander Gro=C3=9F http://therightstuff.de/ --001a114184fa83aeae0552c83250--