Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

John Musbach

macrumors regular
Original poster
Nov 8, 2007
182
0
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! :)
 
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...
 
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:
 
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! :)
 
thanks, I will try ls -lsah and report back
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. :(
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.