How to list the files and folders in a directory with its total size in Linux?

10.7k views Asked by At

I can't get any command to list all the files and folders with its total size in a directory without showing all the sub-directories. e.g. I have a directory as

ls /home/kayan/data/
data-1 data-2 test.txt readme.txt

here data-1 and data-2 are two folder having plenty of sub-folders and files. Their actual sizes are 123G and 115G.

When I am using "du" command it is listing all the sub-directories and taking too much time. When I am using "ll" it is not showing the actual size of a folder which has sub-folders. What I want is like something:

data-1 123G
data-2 115G
test.txt 12K
readme.txt 14K
1

There are 1 answers

1
Sven Jung On BEST ANSWER

You can use "du" command to achieve that. Go to the right directory and type

du -sh *

It will list all files and directories in the current directory like

123G data-1
115G data-2
12K test.txt
14K readme.txt