Re: Display folder list with numbers of files in each folder and it’s sub folders
If you need to find where you may have large numbers of files stored it is useful to display a list of folders together with how many files are contained within that folder and its subfolders. This enables you to drill down to the area where the most files are stored.
# du -a | cut -d/ -f2 | sort | uniq -c | sort -nr
As an example, I will run this command in my /httpdocs folder, here is the output:
1959 wp-content
424 wp-includes
333 wp-admin
30 img
28 test
22 var
This immediately informs me where the most files are stored and that I have 1,959 files within my wp-content folder and it’s sub folders.
To get the disk usage of these folders instead, do this:
# du -h --max-depth=1
The output is as follows:
98M ./wp-content 4.0K ./plesk-stat 4.0K ./picture_library 20K ./css 128K ./test 5.7M ./wp-includes 3.8M ./wp-admin 8.0K ./blogs 144K ./img 4.0K ./tmp 124K ./var 108M .
These are useful tools when investigating disk space usage problems.