How to get a full size of directory without listing the files/dir within?

I am able to get a size of a directory at the end of the du -h directoryname. But is there a way to get the size without it listing the files/directories within?

I'm currently doing it like this:

du -h directoryname | tail -n1

How to keep an index of directory sizes? Is there an Ubuntu application/software for that?


Solution 1:

The -s option for du will give you an output which is just the summary, so swap your command to:

du -sh /path/to/directory

Solution 2:

You can use:

du -d 0 -h directoryname

From man du:

-d, --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;

If you want a GUI application to do that, you can use Disk Usage Analyzer (or baobab), to check:

enter image description here

Or use the 'Properties' feature (in most file managers):

enter image description here

The last one I think caches a bit unless a noticeable change occurs (in Nemo anyway).