I need to make a shell script to get the size of every www directory of my users home folder
I need开发者_如何学运维 somethings like
USERNAME - WWWdirsize
USERNAME - WWWdirsize
TOTAL www Size = ...
I know that I have to play with the du unix command
any help?
To get the recursive size of a folder: du -hs | cut -f 1
So to get the size of each user's www folder:
ls /home | while read username; do echo "$username $(du -hs "/home/$username/public_html" | cut -f 1)"; done
Try something like this:
du -sh /home/*/public_html
Output on my system:
0 /home/brokeneggs/public_html
3.1G /home/jonhall/public_html
178M /home/stubuntu/public_html
You can do further parsing of the output if you want only usernames to appear, and not full paths, for instance.
try this command to calculate:
du -sch .
精彩评论