Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: extracting fields
- X-seq: zsh-users 6952
- From: James Devenish <j-devenish@xxxxxxxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: extracting fields
- Date: Mon, 22 Dec 2003 18:09:15 +0800
- In-reply-to: <25039.1072086714@xxxxxxxxxxx>
- Mail-followup-to: zsh-users@xxxxxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20031222083820.GA81148@xxxxxxxxxxxxxxxxxxxx> <25039.1072086714@xxxxxxxxxxx>
In message <25039.1072086714@xxxxxxxxxxx>
on Mon, Dec 22, 2003 at 10:51:54AM +0100, Oliver Kiddle wrote:
> Dominic Mitchell wrote:
> 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#*|}%%|*}
Yes, I think he might simply have been overlooking the ${...${...}...}
construct. For example:
> Dominic Mitchell wrote:
> % echo $pg_tables[0]
> public|book|table|dom
[...]
> Now I'm interested in the table name which is the 2nd field.
Selecting "column c" of "record r" could be like this:
% integer r=1 c=2; echo ${${(s:|:)pg_tables[$r]}[$c]}
Messages sorted by:
Reverse Date,
Date,
Thread,
Author