Linux: Calculate Sizes of Individual Directories Within a Directory

This is to calculate sizes of individual directories within a selected directory…

An example for a /directory/subdirectory directory is as follows:

A single-line version:

for each in $(ls /directory/subdirectory) ; do du -sh "/directory/subdirectory/$each" ; done

A multi-line version:

for each in $(ls /directory/subdirectory)
do
    du -sh "/directory/subdirectory/$each"
done
Advertisements
This entry was posted in Linux and tagged , , , . Bookmark the permalink.