From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6797 invoked from network); 22 Dec 2003 09:48:00 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 22 Dec 2003 09:48:00 -0000 Received: (qmail 15055 invoked by alias); 22 Dec 2003 09:47:45 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 6951 Received: (qmail 14994 invoked from network); 22 Dec 2003 09:47:45 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 22 Dec 2003 09:47:45 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [193.109.254.211] by sunsite.dk (MessageWall 1.0.8) with SMTP; 22 Dec 2003 9:47:45 -0000 X-VirusChecked: Checked X-Env-Sender: okiddle@yahoo.co.uk X-Msg-Ref: server-15.tower-36.messagelabs.com!1072086463!2661848 X-StarScan-Version: 5.1.15; banners=-,-,- Received: (qmail 21508 invoked from network); 22 Dec 2003 09:47:43 -0000 Received: from iris.logica.co.uk (158.234.9.163) by server-15.tower-36.messagelabs.com with SMTP; 22 Dec 2003 09:47:43 -0000 Received: from gmcs3.local ([158.234.142.61]) by iris.logica.co.uk (8.12.3/8.12.3/Debian -4) with ESMTP id hBM9lhuB021090 for ; Mon, 22 Dec 2003 09:47:43 GMT Received: from gmcs3.local (localhost [127.0.0.1]) by gmcs3.local (8.11.6/8.11.6/SuSE Linux 0.5) with ESMTP id hBM9psA25041 for ; Mon, 22 Dec 2003 10:51:54 +0100 X-VirusChecked: Checked X-StarScan-Version: 5.0.7; banners=.,-,- In-reply-to: <20031222083820.GA81148@ppe.happygiraffe.net> From: Oliver Kiddle References: <20031222083820.GA81148@ppe.happygiraffe.net> To: zsh-users@sunsite.dk Subject: Re: extracting fields Date: Mon, 22 Dec 2003 10:51:54 +0100 Message-ID: <25039.1072086714@gmcs3.local> Dominic Mitchell wrote: > I'm trying to extract stuff from a string in a similiar manner to cut(1) > and getting rather unstuck. I'm sure that there's a simpler answer, but > I can't seem to find it. > Now I'm interested in the table name which is the 2nd field. But I > can't work out how. I've been playing with things like this: > > % echo ${(@s:|:)pg_tables[2]} Zsh has no concept of two-dimensional arrays so you can't split every element of an array and expect indexing tow work on each element like that. You would have to have a for loop for each array element. Alternatively, if it is is the second field you want, you can probably do: ${${pg_tables#*|}%%|*} Oliver