Monday, May 6, 2024
 Popular · Latest · Hot · Upcoming
68
rated 0 times [  68] [ 0]  / answers: 1 / hits: 216827  / 3 Years ago, wed, may 12, 2021, 10:17:15

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.


More From » files

 Answers
7

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.


[#43815] Thursday, May 13, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
nguai

Total Points: 216
Total Questions: 108
Total Answers: 116

Location: Hong Kong
Member since Thu, Dec 16, 2021
2 Years ago
;