LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   help understanding this command (https://www.linuxquestions.org/questions/linux-general-1/help-understanding-this-command-233177/)

vince_2x 09-20-2004 10:21 PM

help understanding this command
 
Hi there!
does any one have an idea of how I would sum up the total disk space use by a user's files in a particular directory.

for example, say I wanna find out the total disk space use by user samy in the /var/ directory..

thanks

btmiller 09-20-2004 11:22 PM

Hmmm ... good question. Maybe something like:

find . -user <username> -type f -ls | awk 'BEGIN {total=0} {total += $7} END {print total}'

would work. Of course, if /var is its own partition, and you have the quota utilities installed, you can just use repquota. If you're going to try to limit the amount of disk users can use, that's probably the way to go.

aiza 09-20-2004 11:48 PM

Re: help understanding this command
 
Quote:

Originally posted by vince_2x
Hi there!
does any one have an idea of how I would sum up the total disk space use by a user's files in a particular directory.

for example, say I wanna find out the total disk space use by user samy in the /var/ directory..

thanks

du -sh /directory

Tinkster 09-21-2004 12:01 AM

Re: Re: help understanding this command
 
Quote:

Originally posted by aiza
du -sh /directory
Where does samy come into the picture?


Cheers,
Tink

vince_2x 09-21-2004 12:42 AM

vince_2x
 
Oh thanks a lot btmiller.. this is exactly what I wanna do .. somehow I did modify the command a bit to get precise results.. somethink like


find /var/ -user $USER -type f -exec du -s -k -h {} \; | awk 'BEGIN {total=0}{total += $1}END{print total}
^^^^^^^^^^^^^^

thanks a lot


All times are GMT -5. The time now is 12:08 AM.