zsh-users
 help / color / mirror / code / Atom feed
* Re: part of an associativz array
@ 2006-04-01  2:27 Bart Schaefer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2006-04-01  2:27 UTC (permalink / raw)
  To: zsh-users

On Mar 31, 10:35pm, Marc Chantreux wrote:
}
} something like : 
} 
} $user[login,uid]
} 
} any idea ?

    ${(v)user[(I)(login|uid)]}

However, you get them in the indeterminate order in which they appear
in the hash, rather than in the order given in the pattern.  To get
them in predictable order, you need something a lot uglier, like

    ${(e):-\$user\[{login,uid}\]}


^ permalink raw reply	[flat|nested] 2+ messages in thread

* part of an associativz array
@ 2006-03-31 20:35 Marc Chantreux
  0 siblings, 0 replies; 2+ messages in thread
From: Marc Chantreux @ 2006-03-31 20:35 UTC (permalink / raw)
  To: zsh-users

Hi all, 

some days ago, someone posted this fantastic code :

local -A user
while { IFS=: read 'user['${^=:-login passwd uid gid gecos home shell}']' } {
    if (( ${user[uid]} > 100 )) { print $user[login] }
}
< /etc/passwd

very perlish way to do ! i loved it ... but now i want to extract a part of the aray.

something like : 

$user[login,uid]

any idea ?

regards
mc


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-04-01  2:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-01  2:27 part of an associativz array Bart Schaefer
  -- strict thread matches above, loose matches on Subject: below --
2006-03-31 20:35 Marc Chantreux

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).