Re: How can I find home directory from login-id. (225 Views)
Reply
Occasional Visitor
Anil Jaglan
Posts: 2
Registered: ‎09-05-2001
Message 1 of 6 (225 Views)
Accepted Solution

How can I find home directory from login-id.

[ Edited ]

Guys,
I want to calculate disk usage per user basis.
I wrote something like:
#! /usr/bin/ksh
for i in ` listusers | sort | awk '{print $1}' `
do
du -ks ~$i
done

The ~(tilda) did't work as expected. Can you point out what's wrong.

thanx in advance

 

 

 P.S.This thread has been moved from HP-UX>System Administration to HP-UX >  langages- HP Forums Moderator

Honored Contributor
Sridhar Bhaskarla
Posts: 6,350
Registered: ‎08-15-2001
Message 2 of 6 (225 Views)

Re: How can I find home directory from login-id.

Anil,

Try

du -sk `eval echo ~$user`

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Honored Contributor
Joseph C. Denman
Posts: 660
Registered: ‎03-13-2000
Message 3 of 6 (225 Views)

Re: How can I find home directory from login-id.

How about something like this??


#! /usr/bin/ksh
for i in ` listusers | sort | awk '{print $1}' `
do
x=`grep $i /etc/passwd | cut -f6 -d:`
y=`du -ks $x`
echo $i $x $y
done

...jcd...
If I had only read the instructions first??
Honored Contributor
linuxfan
Posts: 874
Registered: ‎10-19-2000
Message 4 of 6 (225 Views)

Re: How can I find home directory from login-id.

Hi Anil,

~$i seems to be working but in any case you
could try something like

#! /usr/bin/ksh
for i in ` listusers | sort | awk '{print $1}' `
do
du -ks $(pwget -n $i |cut -d: -f6)
done

-HTH
Ramesh
They think they know but don't. At least I know I don't know - Socrates
Occasional Visitor
Anil Jaglan
Posts: 2
Registered: ‎09-05-2001
Message 5 of 6 (225 Views)

Re: How can I find home directory from login-id.

All 10 points to jcd

cool
Honored Contributor
linuxfan
Posts: 874
Registered: ‎10-19-2000
Message 6 of 6 (225 Views)

Re: How can I find home directory from login-id.

Hi Anil,

Just curious, was there anything wrong in the other solutions provided?

-Ramesh
They think they know but don't. At least I know I don't know - Socrates
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.