Re: How can I find home directory from login-id. (152 Views)
Reply
Occasional Visitor
Anil Jaglan
Posts: 2
Registered: ‎09-05-2001
Message 1 of 6 (152 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

Please use plain text.
Honored Contributor
Sridhar Bhaskarla
Posts: 6,350
Registered: ‎08-15-2001
Message 2 of 6 (152 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
Please use plain text.
Honored Contributor
Joseph C. Denman
Posts: 660
Registered: ‎03-13-2000
Message 3 of 6 (152 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??
Please use plain text.
Honored Contributor
linuxfan
Posts: 874
Registered: ‎10-19-2000
Message 4 of 6 (152 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
Please use plain text.
Occasional Visitor
Anil Jaglan
Posts: 2
Registered: ‎09-05-2001
Message 5 of 6 (152 Views)

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

All 10 points to jcd

cool
Please use plain text.
Honored Contributor
linuxfan
Posts: 874
Registered: ‎10-19-2000
Message 6 of 6 (152 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
Please use plain text.
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