These patches add a new option to ls(1), du(1) and df(1) that enables sizes to be printed with thousands separators, which is often much more human-readable than the so-called "human-readable" output produced by the -h option. Sample output from ls(1): -rw-r--r-- 1 foo bar 151,950,474 Oct 4 16:22 b1.img.gz -rwxr-xr-x 1 foo bar 3,543 Oct 4 19:16 mirror.sh -rw-r--r-- 1 foo bar 1,249,240 Oct 5 13:22 t1.img.find -rw-r--r-- 1 foo bar 6,291,456,000 Oct 4 19:05 t1.img -rw-r--r-- 1 foo bar 149,764,301 Oct 4 19:23 t1.img.gz -rw-r--r-- 1 foo bar 2,083,980 Oct 5 13:22 t1.img.ls-alR Sample output from du(1): 11,828 /home/alfred 470,344 /home/berta 866,424 /home/chris 9,808 /home/donald 112 /home/emma 1,358,516 total Sample output from df(1): Filesystem 1K-blocks Used Avail Capacity Mounted on /dev/ad0s1a 1,012,974 62,418 869,520 7% / /dev/ad0s1d 10,154,158 31,424 9,310,402 0% /var /dev/ad0s1e 10,154,158 1,544,566 7,797,260 17% /usr /dev/ad0s1f 128,009,212 1,358,518 116,409,958 1% /home /dev/md0 297,326 20 273,520 0% /tmp The thousands separators are enabled with a new option "-," (a comma). I'm aware that this is against style(9) and it will be changed (see discussion below). Using the comma is just temporary. The "-," and -h options are mutually exclusive; they override each other so shell aliasing works as expected. It is expected that users create shell aliases or shell functions for their convenience that contain the option, for example: alias ll="ls -l," or: ll() { ls -l, "$@" | less -EM; } The code uses the separation character and grouping specification accoding to the current locale set by the user (LC_NUMERIC, LC_ALL or LANG, respectively). If the locale does not specify thousands separators, but the user still requests them by specifying the option, then a comma will be enforced to be used as the separator, unless the locale already specifies the comma as the decimal point, in this case a period will be used. If the locale doesn't specify grouping, then groups of three digits will be separated. These patches apply to RELENG_6 and RELENG_5 as of 2006-11-22, both of which have been tested. The patches for ls(1) and du(1) apply cleanly to HEAD (7-current), but the patch for df(1) requires minor modifications because of the recent addition of the "kflag" variable. Other than that, all patches work fine on HEAD. The following files are patched: df.patch (relative to src/bin/df): df.c du.patch (relative to src/usr.bin/du): du.c ls.patch (relative to src/bin/ls): ls.c ls.h print.c TODO: -1- Using "," as an option character is against style(9) (even though it is easy to remember and easy to type). Select a suitable option letter, preferably the same in all tools. In ls(1) the following letters are currently unused: -DEJKMNOQVXYejvyz All of them happen to be unused in du(1) and df(1), too, so using one of them would be OK. Maybe -D ("Digit separators") would be a good choice. -2- Add the new option to the Usage output of the tools. -3- Add the new option to the manual pages. -4- Consider adding the common code to libutil (that's also where humanize_number(3) already lives). -5- Maybe it could be integrated somehow in the printf(3) code. I have no idea how, though. -6- Add the feature to more tools. For example, it might be useful with "netstat -i", "ipfw show" and others. --