• Utility corner
dirsize - a simple utility to count file sizes in a directory
What is this?
dirsize is a simple utility that totals the sizes of files in a particular
directory. Unlike the standard
du, it is not concerned with
working out the total disk space usage, but the actual size of the file
contents. dirsize will always report a smaller figure than
because it will ignore the storage of inodes, etc. More importantly,
dirsize should give the same results when applied to the same files
on different systems. This can not be said for
the overheads involved in maintaining the directory structure are
The main intended application of dirsize is to act as a quick check that
directory trees have been copied correctly from one system to another using,
du is often unhelpful here, because
it is not expected to report exactly the same total size on different
Run dirsize with one or more directories as arguments.
$ dirsize [directories...]
If no directories are specified, dirsize works on the current directory.
Building and installing
Unpack the source code bundle (see the Downloads section at the end)
$ sudo make install
Include hidden files. The default is to ignore them.
Directory only; do not recurse into any subdirectories.
Dormat file size in kilobytes, etc. See notes below about how these
figures should be interpreted. The default is to output the exact number
of bytes counted.
Show the help text.
Summarize. Only show the totals for top-level directories. This does not
prevent lower-level directories contributing to those totals; to eliminate
subdirectories altogether, use -d.
Show the version and quit.
- dirsize does not interpret symbolic links in any way. They are completely
ignored, and neither the link nor the target contributes to the total.
This is because
dirsize is concerned with actual file sizes,
not filesytem organization
- For the same reason,
dirsize also ignores pipes,
special files, etc
- For the purposes of this utility, a megabyte is 1024 kB, and a gigabyte is 1024 Mb
Legal and copying
dirsize is maintained by Kevin Boone (kevin at railwayterrace dot com)
and is distributed under the terms of the GNU Public Licence, version 3.
In short, you may use it however you wish other than to claim it as your own work
(as if you would want to) but there is no warranty of any kind.
The most up-to-date source is available from the
Source code bundle<