From: dom@happygiraffe.net (Dominic Mitchell)
To: Oliver Kiddle <okiddle@yahoo.co.uk>
Cc: zsh-users@sunsite.dk
Subject: Re: extracting fields
Date: Mon, 22 Dec 2003 10:24:28 +0000 [thread overview]
Message-ID: <20031222102428.GA84695@ppe.happygiraffe.net> (raw)
In-Reply-To: <25039.1072086714@gmcs3.local>
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
prev parent reply other threads:[~2003-12-22 10:24 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-12-22 8:38 Dominic Mitchell
2003-12-22 9:51 ` Oliver Kiddle
2003-12-22 10:09 ` James Devenish
2003-12-22 10:24 ` Dominic Mitchell [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20031222102428.GA84695@ppe.happygiraffe.net \
--to=dom@happygiraffe.net \
--cc=okiddle@yahoo.co.uk \
--cc=zsh-users@sunsite.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).