5

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

2 Answers 2

5

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
1
  • Oooh, I see, I though I could use -b as a shorthand for --apparent-size.
    – AndreKR
    Jan 23, 2014 at 12:56
4

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.

You must log in to answer this question.

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