Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
extracting fields
- X-seq: zsh-users 6950
- From: dom@xxxxxxxxxxxxxxxx (Dominic Mitchell)
- To: zsh-users@xxxxxxxxxx
- Subject: extracting fields
- Date: Mon, 22 Dec 2003 08:38:20 +0000
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author