Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

linux command line: du --- how to make it show only total for each directories

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.

like image 242
Andrew_1510 Avatar asked Apr 11 '12 09:04

Andrew_1510


People also ask

How do I count only directories in Linux?

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.

Which command displays the total block usage for all files in a directory?

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.

What options would you use with the du command to show the total space used in the home 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.

What is the command to display the total disk usage of the current directory?

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.


2 Answers

This works with coreutils 5.97:

du -cksh *

like image 182
DanS Avatar answered Nov 13 '22 01:11

DanS


On my version of du (from coreutils 8.14) this works:

du -h -d 1 

-h is for human readable sizes.

like image 31
Albert Veli Avatar answered Nov 13 '22 01:11

Albert Veli