2025-03-14 21:59:59 -06:00
|
|
|
# du
|
|
|
|
|
|
|
|
|
|
> Disk usage: estimate and summarize file and directory space usage.
|
|
|
|
|
> More information: <https://keith.github.io/xcode-man-pages/du.1.html>.
|
|
|
|
|
|
|
|
|
|
- List the sizes of a directory and any subdirectories, in the given unit (KiB/MiB/GiB):
|
|
|
|
|
|
|
|
|
|
`du -{{k|m|g}} {{path/to/directory}}`
|
|
|
|
|
|
|
|
|
|
- List the sizes of a directory and any subdirectories, in human-readable form (i.e. auto-selecting the appropriate unit for each size):
|
|
|
|
|
|
|
|
|
|
`du -h {{path/to/directory}}`
|
|
|
|
|
|
|
|
|
|
- Show the size of a single directory, in human-readable units:
|
|
|
|
|
|
|
|
|
|
`du -sh {{path/to/directory}}`
|
|
|
|
|
|
|
|
|
|
- List the human-readable sizes of a directory and of all the files and directories within it:
|
|
|
|
|
|
|
|
|
|
`du -ah {{path/to/directory}}`
|
|
|
|
|
|
2025-12-16 10:20:31 -07:00
|
|
|
- List the human-readable sizes of a directory and any subdirectories, up to `n` levels deep:
|
2025-03-14 21:59:59 -06:00
|
|
|
|
2025-12-16 10:20:31 -07:00
|
|
|
`du -h -d {{n}} {{path/to/directory}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- List the human-readable size of all `.jpg` files in subdirectories of the current directory, and show a cumulative total at the end:
|
|
|
|
|
|
2025-12-16 10:20:31 -07:00
|
|
|
`du -ch */*.jpg`
|