From: Motoi Washida <a66@h8.dion.ne.jp>
To: Wataru Kagawa <wkagawa@jota.gsc.riken.go.jp>
Cc: zsh-users@sunsite.dk
Subject: Re: outputs of _users and _hosts to arrays
Date: Mon, 25 Jul 2005 18:15:32 +0900 [thread overview]
Message-ID: <10C0AB35-42EC-4270-8CC0-8ABDA5428A83@h8.dion.ne.jp> (raw)
In-Reply-To: <3BF4526D-BFA6-46C7-A977-BD43DFAD4C07@jota.gsc.riken.go.jp>
Hi Wataru,
On 07/25/2005, at 14:18, Wataru Kagawa wrote:
> Hi Bart,
>
> Thanks for the help.
> After googling, I found out that _users extract usernames from /etc/
> passwd and _hosts extract hostnames from /etc/hosts.
>
> So, I can use parameter expansions like,
>
> users=( ${$( cat /etc/users | cut -d : -f 1,7 | grep -v "#" )//:*/} )
If you do that on Mac OS X, maybe you can't get even your name. ;-)
The more general way is using $userdirs special variable.
Load zsh/parameter module,
% zmodload -i zsh/parameter
and,
% users=( $userdir[(I)*] )
I think you can also get user names by calling hash builtin function.
But I had to rebuild named directory hash table to get expected
results on some platforms.
You might need to call this,
% builtin hash -fd
and get hash table entries,
% users=( ${${(f)"$(builtin hash -d)"}%\=*} )
> hosts=( ${$( cat /etc/hosts | cut -d : -f 1,7 | grep -v "#" )//:*/} )
>
> to get what I need.
This has the same problem, but I don't know a better way well. Using
some functions from Perl or some other language?
next prev parent reply other threads:[~2005-07-25 9:15 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-07-24 7:05 Wataru Kagawa
2005-07-24 9:33 ` Bart Schaefer
2005-07-25 5:18 ` Wataru Kagawa
2005-07-25 5:38 ` Wataru Kagawa
2005-07-25 9:15 ` Motoi Washida [this message]
2005-07-26 1:56 ` Wataru Kagawa
2005-07-26 16:23 ` Motoi Washida
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=10C0AB35-42EC-4270-8CC0-8ABDA5428A83@h8.dion.ne.jp \
--to=a66@h8.dion.ne.jp \
--cc=wkagawa@jota.gsc.riken.go.jp \
--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).