sort -h
I recently discovered the
-h
switch of GNU sort, added in the coreutils 7.5 release from Aug 20, 2009. With this switch,sort
will do a numeric sort of human-readable size numbers, i.e. it will accept “42M” and “1.3G” as numbers and put them in the right order.
Alas, Mac OS X ships with the 5.93 version of sort from 2005.