Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: extracting fields
- X-seq: zsh-users 6951
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: extracting fields
- Date: Mon, 22 Dec 2003 10:51:54 +0100
- In-reply-to: <20031222083820.GA81148@xxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20031222083820.GA81148@xxxxxxxxxxxxxxxxxxxx>
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author