Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The du command in my solaris environment has very terse help, no man page, and doesn't support the --max-depth option seen in the linux world.

I want to know how much space a given directory occupies. What's the simplest way to get this in Solaris?

share|improve this question
Found an answer. Rather than deleting the question, I figure someone else might like to know the answer: du -sk <dirname> – Brian Vandenberg May 10 '11 at 19:15
you can answer your own question then. – Nitrodist May 10 '11 at 19:56
To add to what @Nitrodist suggests: Please accept an answer or post your own and accept it once that is possible. This way, the system recognizes this issue as solved and doesn't bump it to the front page in the future. – Daniel Beck May 10 '11 at 20:35
I have to wait 8 hours before I can post an answer to my own question. – Brian Vandenberg May 10 '11 at 20:44
Solaris provides a du man page, but your sysadmin may have chosen not to install man pages. You can find them online at – alanc May 10 '11 at 23:59
up vote 4 down vote accepted
du -s <dirname>

... or to get it to print the size in kilobytes:

du -sk <dirname>

Additionally, if you have the right OpenCSW package(s) installed (who doesn't?), the GNU variants of this (and other tools) are available in /opt/csw/bin, often with a g tacked onto the front (gdu, gsed, gawk, etc). For example:

/opt/csw/bin/gdu --max-depth=0 <dirname>
share|improve this answer

Hack, but should work:

du | egrep -v '.*/.*/.*/'

This will print only the lines with 2 or fewer '/' marks.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .