[wplug] need to find user HOME dir
Alexandros Papadopoulos
apapadop at cmu.edu
Tue Jul 1 01:11:09 EDT 2003
On Tuesday 01 July 2003 00:55, Tim Lesher wrote:
> 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
Ah, of course! Forgot the -w there...
HOMEDIR=`grep -w $USER /etc/passwd | cut -d ":" -f 6`
:-)
-A
--
http://andrew.cmu.edu/~apapadop/pub_key.asc
3DAD 8435 DB52 F17B 640F D78C 8260 0CC1 0B75 8265
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: signature
Url : http://penguin.wplug.org/pipermail/wplug/attachments/20030701/dc62f2b2/attachment-0001.bin
More information about the wplug
mailing list