Languages and Scripting
Showing results for 
Search instead for 
Do you mean 

How can I find home directory from login-id.

SOLVED
Go to Solution
Occasional Visitor

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

5 REPLIES
Honored Contributor 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
Honored Contributor Honored Contributor

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

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

All 10 points to jcd

cool
Highlighted
Honored Contributor 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