Is there a command to list a directory total size and then each sub-folder and files inside it .

I also want to sort them by increasing order so that I can see which folder is greater in size.

du -sh * | sort -h

will get you a human-readable ascending list of the sizes of files and subdirectories in your current directory,

du -sh 

will summarize the current directory size.

| improve this answer | |
  • 1
    The 1st command will error out if a file starts with a -. – Rinzwind Oct 8 '16 at 11:54

My answer is like below :

i used du command for that purpose .

du : Summarize disk usage of each FILE, recursively for directories.

As the picture below i want to see the size of a folder name test and recursively the sub folders and each file in kb :

enter image description here

| improve this answer | |

You can do ls -sh to list the file size of the files and folder in the current directory
ls -shR * will list the size and name of files recursively

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.