{"id":2503,"date":"2009-12-15T12:22:00","date_gmt":"2009-12-15T12:22:00","guid":{"rendered":"http:\/\/www.b.shuttle.de\/hayek\/Hayek\/Jochen\/wp\/blog-en\/2009\/12\/15\/bash-version-4-and-associative-arrays\/"},"modified":"2009-12-15T12:22:00","modified_gmt":"2009-12-15T12:22:00","slug":"bash-version-4-and-associative-arrays","status":"publish","type":"post","link":"https:\/\/wp.jochen.hayek.name\/blog-en\/2009\/12\/15\/bash-version-4-and-associative-arrays\/","title":{"rendered":"bash version 4 and associative arrays"},"content":{"rendered":"<p>\t\t\t\tThe new builtin array variable <span><span>BASH_ALIASES<\/span><\/span> is a nice example for an associative array.<br \/>\nIf you do an &#8221;<span>echo ${BASH_ALIASES[@]}<\/span>&#8221; you see all the values, if you do a &#8220;<span><span>set | fgrep <\/span>BASH_ALIASES<\/span>&#8221; you see, to what the indexes map.<\/p>\n<p><b>Update:<\/b> <br \/><b><\/b><br \/>\nIn December, when I got aware of the new feature, I thought, there is no way to get the list of indexes.<br \/>\nBut there is:\u00a0 <span><span>${!name[@]}<\/span><\/span> and <span><span>${!name[*]}<\/span><\/span> return the <i>list of array keys<\/i>. This gets explained in the section <i>Parameter Expansion<\/i>.<b> <\/b>I am sorry, if my former statements caused confusion.<br \/><b><\/b><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The new builtin array variable BASH_ALIASES is a nice example for an associative array. If you do an &#8221;echo ${BASH_ALIASES[@]}&#8221; you see all the values, if you do a &#8220;set | fgrep BASH_ALIASES&#8221; you see, to what the indexes map. Update: In December, when I got aware of the new feature, I thought, there is [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false,"_share_on_mastodon":"0"},"categories":[666],"tags":[890],"class_list":["post-2503","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-associative-array"],"share_on_mastodon":{"url":"","error":""},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/paO0kP-En","jetpack_likes_enabled":true,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/wp.jochen.hayek.name\/blog-en\/wp-json\/wp\/v2\/posts\/2503","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wp.jochen.hayek.name\/blog-en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wp.jochen.hayek.name\/blog-en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wp.jochen.hayek.name\/blog-en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wp.jochen.hayek.name\/blog-en\/wp-json\/wp\/v2\/comments?post=2503"}],"version-history":[{"count":0,"href":"https:\/\/wp.jochen.hayek.name\/blog-en\/wp-json\/wp\/v2\/posts\/2503\/revisions"}],"wp:attachment":[{"href":"https:\/\/wp.jochen.hayek.name\/blog-en\/wp-json\/wp\/v2\/media?parent=2503"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wp.jochen.hayek.name\/blog-en\/wp-json\/wp\/v2\/categories?post=2503"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wp.jochen.hayek.name\/blog-en\/wp-json\/wp\/v2\/tags?post=2503"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}