Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • 70
    ...unless you have hardlinks ;-) stackoverflow.com/questions/19951883/… Commented Feb 20, 2015 at 10:31
  • 5
    It works very nice with find e.g. to count the amount of space in specific subdirectories in current path: $ find . -type d -name "node_modules" -prune -exec du -sh {} \; Commented Apr 16, 2019 at 6:02
  • 1
    @Rmano is there a single command that works with hardlinks? Commented Mar 19, 2021 at 22:02
  • @CharlieParker no that I know of... Commented Mar 20, 2021 at 10:51
  • I'm looking right now at a folder I just copied from an external drive. It contains four files (no hardlinks). du -ba $folder reports that each of these files is identical in size across the copied folders, but the total at the folder level does not match. du -bs, du -h, etc., same answer. (One folder size is six bytes more than the sum of the files; the other is ~10% larger.) I've seen this issue before comparing a folder on an external drive. Is there any unix command that will reliably report two folders containing identical files as being the same "size"? Commented May 8, 2021 at 20:15