Operating System - Linux
1830340 Members
2329 Online
110001 Solutions
New Discussion

How can I get the disk usuage of a perticular user

 
SOLVED
Go to solution
Mohammed Haris Khan
Occasional Advisor

How can I get the disk usuage of a perticular user

Hi,

I have a user request to provide the disk usuage of the user's home dir with the names

I issued this command and got only the disk usuage and ID's from the /home dir

#du -sk * | sort -rn

7468504 remoquil
5803904 pzhysl
3069352 7en0fm
2033224 wabtec
1966224 paez
1888472 mentordata
1810456 infodba
1650224 tek
1536368 reydl2
1443248 redquest
1380168 nzr3k0
1283928 tanney
1124520 gz1tbp
852048 export
759984 yell31
723312 kzd0d7
702120 xztmhq
641744 mesparza
616408 bz1r42
462456 radochon
433568 zz6cw0
433248 rongkobu
395800 bedenfie

But i need the users names to be printed from /etc/passwd files too with it

Eg :

Disk usuage ID Names
7468504 remoquil selva kumar
5803904 pzhysl rajesh baskar
3069352 7en0fm harish khan
2033224 wabtec senthil kumar
1966224 paez santhosh kumar
1888472 mentordata priya
1810456 infodba jeyram

Can someone provide me a simple script to print the diskusuage with id's and get the similarnames from the passwd file

EG:

# awk -F ";" '(print $1 "\t" $5)'

will this get only the names fom the /etc/passwd file ????

I need a script for it

Thanks
Harish
3 REPLIES 3
Mohammed Haris Khan
Occasional Advisor

Re: How can I get the disk usuage of a perticular user

I would like to get printed only the names one by one in the next line from the /etc/passwd file. the comments are in 5th column

# awk -F ":" '(print $1 "\t" $5)'/etc/passwd

Please suggest here
Mohammed Haris Khan
Occasional Advisor

Re: How can I get the disk usuage of a perticular user

How can i execute both the commands in the single script :

# cd /home
#du -sk * | sort -rn
#awk 'BEGIN {FS=":"}
>{print $5,}' /etc/passwd

The output which i get from du -sk * must be the input for the /etc/password file. i need only the details of the users who have the disk usuage high
All these needs to be written in a single script

Please help
Dennis Handly
Acclaimed Contributor
Solution

Re: How can I get the disk usuage of a perticular user

>How can I execute both the commands in the single script? I need only the details of the users who have the disk usage high

How high?
If you don't have zillions of users, you can build up an associative array.

cd /home
du -sk * | sort -rn | awk '
BEGIN {
limit = 100 * 1024 # 100 Mb
# create name array
FS=":"
while (getline < "/etc/passwd" == 1){
name[$1] = $5
}
close("/etc/passwd")
FS=" "
}
$1 > limit {
print $0, name[$2]
}'