Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
RE: list keys in assoc array.
- X-seq: zsh-users 6623
- From: Eric.D.Friedman@xxxxxxxxxxxxxx
- To: jprice@xxxxxxxxxxxxxxxxxxxx, zsh-users@xxxxxxxxxx
- Subject: RE: list keys in assoc array.
- Date: Thu, 25 Sep 2003 10:39:14 -0700
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
Yes ;)
You want the k modifier, in parens within a braced reference to your
associative array: ${(k)assoc_array}
typeset -A frodo
frodo=(foo bar frodo bilbo)
for key in ${(k)frodo};
do
echo $frodo[$key]
done
bar
bilbo
-----Original Message-----
From: Jason Price [mailto:jprice@xxxxxxxxxxxxxxxxxxxx]
Sent: Thursday, September 25, 2003 10:26 AM
To: zsh-users@xxxxxxxxxx
Subject: list keys in assoc array.
I've been poking through the man pages, and I can't find how to get a list
of keys from an associative array. Idealy, I'd like something like:
foreach key in array ; do
if [ array[key] = someval ] ; then
do stuff
fi
done
Am I just being blind in the manpages?
Thanks;
Jason
Messages sorted by:
Reverse Date,
Date,
Thread,
Author