Human-readable sizes all over the place

Aug 04, '04 10:19:00AM

Contributed by: paco

I saw this older hint about getting the "human readable" version of information from the df and du commands. As of Panther, at least, the du, df and ls commands all take the -h option. Not only is it no longer necessary to tweak your du or df command to get the behavior, but I think this feature in ls is relatively recent, too.

As far as I can tell, Mac OS did not adopt the GNU fileutils, but they did adopt this nice feature. I find it handy when I'm using a Terminal to use ls -lh, so I don't have to count digits to figure out the sizes. Here's an example:

% ls -lh
total 5504344
-rw-rw-r--  1 paco  staff         42B  3 Aug 20:59 01.gif
-rw-rw-r--  1 paco  staff        872M  3 Aug 22:43 BTV Movie 001.mov
-rw-rw-r--  1 paco  staff          1G  3 Aug 22:47 BTV Movie 002.mov
-rw-rw-r--  1 paco  staff          2M 30 Jul 14:54 GameServices.pdf
-rw-rw-r--  1 paco  staff          1M  3 Aug 17:29 befw11s4_v4_ug.pdf
-rw-r--r--  1 paco  staff        460B  3 Aug 16:58 chiras1-nt
[robg adds: If you use the -h option a lot, you might want to create an alias for it -- I use lsh, which is an alias for ls -alh, the options I use most often with ls.]

Comments (10)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20040804000029326