Operating System - HP-UX
1748169 Members
4025 Online
108758 Solutions
New Discussion юеВ

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

 
SOLVED
Go to solution
Anil Jaglan
New Member

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 5
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
New Member

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

All 10 points to jcd

cool
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