From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 920 invoked from network); 22 Dec 2003 08:38:36 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 22 Dec 2003 08:38:36 -0000 Received: (qmail 12216 invoked by alias); 22 Dec 2003 08:38:22 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 6950 Received: (qmail 12159 invoked from network); 22 Dec 2003 08:38:22 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 22 Dec 2003 08:38:22 -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 8:38:21 -0000 Received: from localhost (localhost.happygiraffe.net [127.0.0.1]) by happygiraffe.net (Postfix) with ESMTP id E77B6B83A for ; Mon, 22 Dec 2003 08:38:20 +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 83624-05 for ; Mon, 22 Dec 2003 08:38:20 +0000 (GMT) Received: by happygiraffe.net (Postfix, from userid 1001) id 5F979B807; Mon, 22 Dec 2003 08:38:20 +0000 (GMT) Date: Mon, 22 Dec 2003 08:38:20 +0000 To: zsh-users@sunsite.dk Subject: extracting fields Message-ID: <20031222083820.GA81148@ppe.happygiraffe.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.5.1i From: dom@happygiraffe.net (Dominic Mitchell) X-Virus-Scanned: by amavisd-new at happygiraffe.net 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. I have the output of psql in an array: pg_tables=( "${(f)$( psql -At -c '\d' )}" ) Which gives an array of entries like these: % echo $pg_tables[0] public|book|table|dom 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]} But I can't figure out how to split the array and then subscript the second word of that newly split array. Any ideas on how I would do this? Thanks, -Dom