Files – How to List Recursive File Sizes in a Directory

file sizefiles

How do I list all the files in a directory and their recursive file sizes?

—edit

I want to see the sizes 'rolled up' to the parent directories in the directory listed. I don't want to see the child directories or their contents or sizes.

Best Answer

I guess the easiest way is by typing ls -l, or ls -lh which will provide the file size in human-readable format (KB, MB, etc).

If 'recursively' means listing all the subsequent folders, e.g.:

/foo/
/foo/bar/ ....

Then you should also add parameter R, like ls -lR or ls -lhR

More information for ls can be found by typing man ls

Update:

The following command as Lekensteyn proposed will probably do the job:

du -h --max-depth=1 <folder>

-h is for human-readable
--apparent-size is another way to display sizes as already stated
--max-depth is the level of subfolders you want to go down to.