Linux du command: how to list subdirectory sizes only.
Make sure you always
test this 'Linux du' script on a test server before implementing it on
a production system !
I can never remember the options for checking the Linux du command so
that I only see the summary of the directories, excluding the list of
files.
What better way than to put up a webpage ?
The options as explained in the manpage are:
- -h, --human-readable
print sizes in human readable format (e.g., 1K 234M 2G) - -c, --total
produce a grand total - --max-depth=N
print the total for a directory (or file, with --all) only if it is N or fewer levels below the command line argument; --max-depth=0 is the same as --summarize
Here it is :
[oracle@testserver]$du -hc --max-depth=1 . 314M ./db1 6.0G ./db2 12K ./db3 12K ./db4 6.3G . 6.3G total