[wplug] need to find user HOME dir

Tim Lesher tim at lesher.ws
Tue Jul 1 00:55:06 EDT 2003


On Tue, Jul 01, 2003 at 12:33:34AM -0400, Alexandros Papadopoulos wrote:
> You mean something like:
> 
> HOMEDIR=`grep $USER /etc/passwd | cut -d ":" -f 6`

This will fall down if the username is a subset of another username in
/etc/passwd, for example, if you have users named "john" and "jo".

Try this (yeah, I'm dating myself, using awk...)

awk -F : "(\$1 == \"$USER\") { print \$6}" < /etc/passwd


-- 
Tim Lesher <tim at lesher.ws>
http://www.lesher.ws




More information about the wplug mailing list