Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

This works:

du -cshm .

But this fails:

du -cshg .

How can I see it in unit of GB?

share|improve this question
add comment

3 Answers

up vote 10 down vote accepted

GNU du has the --block-size option:

du -csh --block-size=1G .

As sajb noted, omitting the block size argument will automatically scale the output (and display the unit). Using any block size argument displays the number but omits the unit.

share|improve this answer
add comment

Use du -B1073741824 but beware, it gives the result in integer-units only, and won't be meaningful with -h

share|improve this answer
add comment

In addition to the previous answers, it also seems to differ between different coreutils versions (or locale?), since on my host I get:

$ du -csh .
32G     .
32G     total
$ du --version | head -1
du (GNU coreutils) 7.4
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.