0

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
Kay
  • 1,957
  • 2
  • 24
  • 46
  • 2
    so you want faster `du -d 1 -h` ? – ymonad Jun 26 '15 at 04:50
  • It should not list all the sub-directories. I want to check the total sizes of each files and folders in a particular directory. – Kay Jun 26 '15 at 04:55
  • 1
    `du -d 1 -h` does not list the sub-directory, instead it shows the size of it, so the result is what you want. However, it does nothing to do with speed-up. It searches through the directory tree. – ymonad Jun 26 '15 at 04:58
  • Possible duplicate of [Using ls to list directories and their total sizes](https://stackoverflow.com/q/1019116/608639) – jww Jul 20 '18 at 13:24

1 Answers1

8

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
Sven Jung
  • 331
  • 1
  • 2
  • 9
  • 1
    Thank you so much. This is exactly what I want. I am surprised, because I had tried with "du -sh" instead of "du -sh *" – Kay Jun 26 '15 at 05:08