up vote 4 down vote favorite
2
share [g+] share [fb]

This works:

du -cshm .

But this fails:

du -cshg .

How can I see it in unit of GB?

link|improve this question

13% accept rate
feedback

3 Answers

up vote 5 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.

link|improve this answer
feedback

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

link|improve this answer
feedback

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
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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