du output as bytes?

Discussion in 'macOS' started by John Musbach, Aug 22, 2008.

  1. John Musbach macrumors regular

    Joined:
    Nov 8, 2007
    #1
    Hi, how do you get directory size outputted as bytes much like Finder does when sshing into a Mac OS X machine (Tiger)? I've seen references to a -b or --bytes switch for use with du but the du that comes with Tiger doesn't support such a switch, so how would one do this? Thanks! :)
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    You could try the -h switch which is supported on a lot of OSX terminal commands. This is human mode so will report in bytes, kilobytes, megabytes etc as appropriate. Not sure when it was added though...
     
  3. r0k macrumors 68040

    r0k

    Joined:
    Mar 3, 2008
    Location:
    Detroit
    #3
    I've always used du -k, which reports in kilobytes instead of "blocks" but I tried du -h and like it even better. Thanks, robbieduncan! My home folder is 64 gig. I guess I really should do a little cleaning. :eek:
     
  4. John Musbach thread starter macrumors regular

    Joined:
    Nov 8, 2007
    #4
    Yes it is possible to report in KB, MB, GB, etc ...but the machine in question contains many small files so using such a measurement to verify file integrity is too inaccurate. The only way to truly verify the integrity of the many small files is to get the directory size in bytes like the Finder does, but there seems to be no way to do this in Terminal. Or am I missing something? Thanks! :)
     
  5. John Musbach thread starter macrumors regular

    Joined:
    Nov 8, 2007
    #6
    thanks, I will try ls -lsah and report back
     
  6. John Musbach thread starter macrumors regular

    Joined:
    Nov 8, 2007
    #7
    While a nice idea, this command appears to just output the size of the items in the current directory instead of doing a recursive sizing like du does. I guess there just isn't a way to duplicate the bytes display that the Finder can do when getting the total size of a directory via the Terminal. :(
     

Share This Page