Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

With du -bh I think I get the apparent size in human readable format:

# du -bh
295K    ./test

However, I would expect the same from du -hb, but I get something else:

# du -hb
301926  ./test

I believe this is the same output as just du -b would give me.

# du --version
du (GNU coreutils) 7.4
share|improve this question
add comment

2 Answers 2

up vote 6 down vote accepted

From the man page for du:

   -b, --bytes
          equivalent to '--apparent-size --block-size=1'
   -h, --human-readable
          print sizes in human readable format (e.g., 1K 234M 2G)

The -h switch will display the output using units, blocks have no units, so these 2 switches aren't suppose to be used together!

NOTE: The command du will therefore display its output based on which ever switch occurs last in the command line arguments.

Examples

b switch examples

$ du -hb XnConvert.x86_64.rpm 
13950768    XnConvert.x86_64.rpm

$ du -b XnConvert.x86_64.rpm 
13950768    XnConvert.x86_64.rpm

$ du -h -b XnConvert.x86_64.rpm 
13950768    XnConvert.x86_64.rpm

h switch examples

$ du -bh XnConvert.x86_64.rpm 
14M XnConvert.x86_64.rpm

$ du -h XnConvert.x86_64.rpm 
14M XnConvert.x86_64.rpm

$ du -b -h XnConvert.x86_64.rpm 
14M XnConvert.x86_64.rpm
share|improve this answer
    
Oooh, I see, I though I could use -b as a shorthand for --apparent-size. –  AndreKR Jan 23 at 12:56
add comment

The -b (show in bytes) and -h (show in a human readable way) options are contradictory.

The last one is the one really used by du.

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.