To display the total file sizes of each user in a common/shared directory (like /tmp)
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix administration > To display the total file sizes of each user in a common/shared directory (like /tmp)




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    To display the total file sizes of each user in a common/shared directory (like /tmp)  
balreddy.gattu@gmail.com


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
06-15-06 12:22 AM

Hello,
Iam trying to find the size of each user used in a common directory.
Do we have any direct command to get the results?

example:  i want to find the total size of each users files  under
/tmp.

Thanks,
Gattu






[ Post a follow-up to this message ]



    Re: To display the total file sizes of each user in a common/shared directory (like /t  
Michael B. Trausch


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
06-15-06 06:28 AM

balreddy.gattu@gmail.com wrote in
<1150310986.555812.100360@y41g2000cwy.googlegroups.com> on Wed, June 14
2006 14:49:
>
> Hello,
> Iam trying to find the size of each user used in a common directory.
> Do we have any direct command to get the results?
>
> example:  i want to find the total size of each users files  under
> /tmp.
>

There are various ways to do this.  Under a system that supports filesystem
quotas, merely enabling quotas would allow you to then view the usage by
user/group on the drive.  Alternatively, you could use a shell script to
collect the information and partially automate the process for you.  For
that, you could probably:

* have the script do an 'ls -lR' on the target directory, cut the user name
out of the list, sort and then uniq it.
* then, loop through that list of users, and have it add the sizes of each
file owned by that user together, presenting each user as it computes it.

How the script does these things is going to vary based on some of the tiny
nuances of your UNIX-like system (e.g., # of spaces in output of 'ls',
whether the filesize is listed in bytes, blocks, or whatever, etc.)

HTH,
Mike

--
Registered Linux User #417338, machine #325045.

...and that is how we know the Earth to be banana-shaped.





[ Post a follow-up to this message ]



    Re: To display the total file sizes of each user in a common/shared directory (like /t  
Stephane Chazelas


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
06-15-06 12:26 PM

On Thu, 15 Jun 2006 05:39:39 GMT, Logan Shaw wrote:
> balreddy.gattu@gmail.com wrote: 
>
> Here's one possible way:
>
> 	cd /tmp && find . -user joebob -type f -print0 |
> 		xargs -0 du -sk |
> 		awk '{t+=$1} END {print t}'
[...]

If you're going to use GNU specific features, then

find . ! -name . -printf '%D-%i:%u:%b\n' |
awk -F: '
! ($1 in already_seen) {
size[$2] += $3
already_seen[$1] = ""
}
END {
sort = "sort -t: -k 2rn"
for (i in size) {
printf "%12s: %.17g\n", i, size[i] * 512 | sort
total += size[i]
}
close(sort)
printf "---\n%12s: %.17g\n", "total", total * 512
}'

The output should be consistent with du's:

stephane: 104386560
test: 48738304
root: 81920
---
total: 153206784
$ du -sB1
153206784

--
Stephane





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 12:22 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register