Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: extracting fields



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