Re: home directory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

--
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux