Shell script to determine the file size in a folder recursively
Solution 1:
find . -exec du -h {}\;
is recursive and displays the size in human readable form.
Or if you're using fish or zsh:
du -h ./**/*
Solution 2:
You can just run
du -sm *
to see the size of all folders in the current directory.
Solution 3:
Or, as an alternative, you could install the freeware Disk Inventory X. Shows you the largest files on your hard drive or in particular directories with a fun visual interface. And you can move items to the trash right from that interface.
Solution 4:
You can also use tree --du -h .
. --du
calculates the size of the contents of directories (like du
) and -h
uses human-readable file sizes.
Or if you only want to see the sizes of the contents of directories, use just du
or du -h
. You can use gsort -h
to sort the output of du -h
.
You can install tree
and gsort
with brew install tree sortutils
.