Skip to content

Instantly share code, notes, and snippets.

@sorokine
Last active November 9, 2019 19:15
Show Gist options
  • Save sorokine/a6c509f343a8be12ba2a2421483d69cb to your computer and use it in GitHub Desktop.
Save sorokine/a6c509f343a8be12ba2a2421483d69cb to your computer and use it in GitHub Desktop.
du on Directories with Spaces

#du on Directories with Spaces

To get the sizes of all subdirectories including the hiddsn ones I typically use the command:

du -sh $(ls -A)

However, this command does not work well if you have directory names with spaces. Here is how you can do it:

find . -maxdepth 1 -print0 | xargs -0 -n1 du -s

or if you want the result nicely sorted nicely and human-readable:

find . -maxdepth 1 -print0 | xargs -0 -n1 du -sh | sort -h
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment