I am doing it by (with coreutils_8.5-1ubuntu6_amd64):
du -sch `find ./ -maxdepth 1 -type d`
I am looking for a simple way (shorter cmd) to find size of subdirectories. Thank you.
The ls command with the -lR options displays the list (in long format) of the sub-directories in the current directory recursively. Then, we use the grep command to search for a string or pattern in the input. In the above command, the ls command lists the contents of all directories.
The du command displays the number of blocks used for files. If the File parameter specified is actually a directory, all files within the directory are reported on. If no File parameter is provided, the du command uses the files in the current directory.
The du command outputs a lot of file-related information that can be confusing when all you are trying to find out is the total size of your directory. To display the total size of a directory, use the -s flag with the command. The -s flag stands for Summarize.
Option 1: Display the Size of a Directory Using the du Command. The du command stands for disk usage. This command is included by default in most Linux distributions. The system should display a list of the contents of your home directory, with a number to the left.
This works with coreutils 5.97:
du -cksh *
On my version of du (from coreutils 8.14) this works:
du -h -d 1
-h is for human readable sizes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With