home directory

Craig White craigwhite at azapple.com
Fri Dec 19 23:01:03 UTC 2008


On Fri, 2008-12-19 at 14:55 -0800, Gordon Messmer wrote:
> Todd Denniston wrote:
> > Craig White wrote, On 12/19/2008 12:03 PM:
> >> getent passwd | grep $1 | awk -F: '{ print $6 }'
> ...
> > Thanks for that getent call suggestion, it simplifies one of my scripts 
> > greatly.
> 
> 
> The grep is useless, and should be discouraged.  Use something like this 
> instead:
> 
> getent passwd "$1" | awk -F: '{ print $6 }'
> or:
> getent passwd "$1" | cut -d: -f6
> 
> Calling "getent passwd" on a machine that uses LDAP as an NSS source 
> causes a full search of the directory, which can be very expensive on 
> large directories.  It's better not to make a habit of doing that.
> 
> Plus, the "grep" method fails if the username that you're searching for 
> is a substring of other usernames in the passwd database.
----
agreed on all accounts...I tossed out the grep idea just as a quick
thought and had doubts about the grep notion but I didn't have the time
to test out other ideas.

Craig




More information about the fedora-list mailing list