12

I'm having some files and folders in the "My Documents" directory. What are the commands to see the size of a file and directory in a terminal?

19

This will summarise the sizes of the directories:

du -h

PS: Although all computer storage is technically "memory", this term is usually reserved for non-persistent storage like RAM and CPU cache.

| improve this answer | |
  • good one for quick recursive results.. +1 – precise Jan 8 '14 at 15:30
5

To see the full size (including whole content) of a folder in a directory, use the command

du -hs YOUR_FOLDER_NAME

To see the full size (including whole content) of all folders and files in a directory, use the command

ls | xargs -I fileorfolder du -hs fileorfolder
| improve this answer | |
4

Try these commands,

cd ~/Documents
ls -shR
| improve this answer | |
  • ls -sh for size and better readability.. and switch -R if recursive output is needed.. +1 – precise Jan 8 '14 at 15:29
  • Not completely satisfied. The size of a folder is given, but not of the total size of the content in the folder. See also this answer about the total size of a folder – loved.by.Jesus Jul 4 '19 at 11:03

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.