Simpler Navigation for Servers and Operating Systems - Please Update Your Bookmarks
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
If you have bookmarked forums or discussion boards in Servers and Operating Systems, we suggest you check and update them as needed.
Languages and Scripting
cancel
Showing results for 
Search instead for 
Did you mean: 

How can I find home directory from login-id.

SOLVED
Go to solution
Anil Jaglan
Occasional Visitor

How can I find home directory from login-id.

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

5 REPLIES
Sridhar Bhaskarla
Honored Contributor

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
Joseph C. Denman
Honored Contributor
Solution

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??
linuxfan
Honored Contributor

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
Anil Jaglan
Occasional Visitor

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

All 10 points to jcd

cool
Highlighted
linuxfan
Honored Contributor

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