From: Eric.D.Friedman@wellsfargo.com
To: jprice@cyberbuzz.gatech.edu, zsh-users@sunsite.dk
Subject: RE: list keys in assoc array.
Date: Thu, 25 Sep 2003 10:39:14 -0700 [thread overview]
Message-ID: <4FE9AD0A3D28CE42A163544072FE867603437DBD@msgsw55cacah01.wellsfargo.com> (raw)
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@cyberbuzz.gatech.edu]
Sent: Thursday, September 25, 2003 10:26 AM
To: zsh-users@sunsite.dk
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
next reply other threads:[~2003-09-25 17:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-09-25 17:39 Eric.D.Friedman [this message]
-- strict thread matches above, loose matches on Subject: below --
2003-09-25 17:26 Jason Price
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4FE9AD0A3D28CE42A163544072FE867603437DBD@msgsw55cacah01.wellsfargo.com \
--to=eric.d.friedman@wellsfargo.com \
--cc=jprice@cyberbuzz.gatech.edu \
--cc=zsh-users@sunsite.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).