Du -sh *

Solved
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

  1. Moderator
    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
    1. 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
    2. Moderator
      Try this (for directories > 20K):

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