From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20601 invoked from network); 22 Dec 2003 10:24:44 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 22 Dec 2003 10:24:44 -0000 Received: (qmail 6803 invoked by alias); 22 Dec 2003 10:24:30 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 6953 Received: (qmail 6748 invoked from network); 22 Dec 2003 10:24:30 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 22 Dec 2003 10:24:30 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [81.6.215.59] by sunsite.dk (MessageWall 1.0.8) with SMTP; 22 Dec 2003 10:24:30 -0000 Received: from localhost (localhost.happygiraffe.net [127.0.0.1]) by happygiraffe.net (Postfix) with ESMTP id 95209B83F; Mon, 22 Dec 2003 10:24:29 +0000 (GMT) Received: from happygiraffe.net ([127.0.0.1]) by localhost (ppe.happygiraffe.net [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 84484-04; Mon, 22 Dec 2003 10:24:29 +0000 (GMT) Received: by happygiraffe.net (Postfix, from userid 1001) id 0104FB83E; Mon, 22 Dec 2003 10:24:28 +0000 (GMT) Date: Mon, 22 Dec 2003 10:24:28 +0000 To: Oliver Kiddle Cc: zsh-users@sunsite.dk Subject: Re: extracting fields Message-ID: <20031222102428.GA84695@ppe.happygiraffe.net> References: <20031222083820.GA81148@ppe.happygiraffe.net> <25039.1072086714@gmcs3.local> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <25039.1072086714@gmcs3.local> User-Agent: Mutt/1.5.5.1i From: dom@happygiraffe.net (Dominic Mitchell) X-Virus-Scanned: by amavisd-new at happygiraffe.net On Mon, Dec 22, 2003 at 10:51:54AM +0100, Oliver Kiddle wrote: > 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. Aha, thank you. I was thinking that I could do it in a for loop. > Alternatively, if it is is the second field you want, you can > probably do: > > ${${pg_tables#*|}%%|*} That's perfect. Thank you very much. Funnily enough, I started going down that line, until I realised I was interested in the second field, not the first. I got the %%|* bit, but didn't make the leap to stripping the first field. Many thanks, -Dom