Subject: ls -lsh
To: None <>
From: Jan Schaumann <>
List: tech-userlevel
Date: 08/05/2004 15:03:05
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable


I'm trying to think what the correct behaviour for 'ls -lsh' is.  The
manual page specifies that '-h' modifies the '-s' option to report sizes
in bytes displayed in human readable format.

The, '-s' does not report anything in number of bytes, but in number of
*units of 512 bytes*.

If we combine 'ls -lsh', then the '-s' column at the beginning is
dropped completely, presumably b/c if we were to display the number of
bytes displayed in a human readable form it would be the same as the
'size' column in human readable form.

Now either we should mention that '-h' overrides '-s', or we should make
'-s' report something in human readable format if both flags are

Humanizing that value would mean -- as far as I understand it -- that if
we had a file that occupies 1024 units of 512 bytes, then that number
should be reported as 1.0K (or maybe 2.0K rounded up).

$ dd if=3D/dev/zero of=3D/var/tmp/foo bs=3D512 count=3D1024
$ ls -ls /var/tmp/foo                    =20
1040 -rw-------  1 jschauma  wheel  524288 Aug  5 14:46 /var/tmp/foo
$ ls -lsh /var/tmp/foo
-rw-------  1 jschauma  wheel  512K Aug  5 14:46 /var/tmp/foo

The last output should have been

$ ls -lsh foo
 2.0K -rw-------  1 jschauma  wheel  512K Aug  5 14:46 foo

to indicate that there are (rounded up) 2K units of 512 byte blocks.

Does that make sense at all?


(FWIW, Linux ls(1) reports
516k -rw-------  1 jschauma cs 512k Aug  5 14:54 /var/tmp/foo
whatever that's supposed to mean.)

A common mistake that people make when trying to design something completely
foolproof is to underestimate the ingenuity of complete fools.

Content-Type: application/pgp-signature
Content-Disposition: inline

Version: GnuPG v1.2.3 (NetBSD)