Du -sh *

Solved
lamou23 Posted messages 218 Status Member -  
bob031 Posted messages 8228 Status Member -
1- Is it possible to get the total size of the directories in /var/www without going into their contents and displaying the sizes of subdirectories, files, and everything?

2- If I want to display only the directories with a size > 20K, is there a command that allows me to do that?

Thank you very much.

3 answers

jipicy Posted messages 40842 Registration date   Status Moderator Last intervention   4 898
 
Hello,

For 1:

du -sh /var/www/*

For 2, you need to look with the command "find" and its options, particularly "-size +20480k", but that only applies to files with the "-type f" option.

Or you can do it with the "1" command and tools like "awk" through a pipe...

--
$ man woman
There is no manual page for woman.

GNU/Linux: Gnu/Linux is Not Ubuntu!
0
lamou23 Posted messages 218 Status Member
 
To get the total size of each directory in `/var/www` without detailing the sizes of individual files, you can use the following command: ```bash du -sh /var/www/*/ ``` This command will provide you with a summary of the size of each directory directly under `/var/www`, omitting individual file sizes while showing the total size for each folder.
0
jipicy Posted messages 40842 Registration date   Status Moderator Last intervention   4 898
 
Try this (for directories > 20K):

find /var/www -maxdepth 1 -type d -exec du -s {} \; | awk '$1 >= 20 { print $0 }'
0