-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 According to Reuben Thomas on 5/25/2009 8:12 AM: > On Mon, 25 May 2009, Eric Blake wrote: > >> Huh? Sorting has indeed been done, unless you requested ls -U. > > Indeed, stupid me (and thanks to the others who pointed out my error). > > So, I'll try again: > > ls -lU|head seems to look at all files in directory. It takes just as > long as ls -l|head, yet it's doing no sorting.
ls -lU will not terminate until it gets a SIGPIPE (or failed write). So even though head only printed the first 10 files, ls will continue to stat() entries until it has populated enough of its stdout pipe to finally trigger the kernel mechanisms that detect that the head process has quit. Depending on how large your directory is, you may end up statting several hundred files before the ls process will be stopped. This is yet another case where the idea of a new coreutil to alter buffering behavior of subsidiary applications would be advantageous - switching ls over to line-buffering mode would detect that the head process went away on the very next file. - -- Don't work too hard, make some time for fun as well! Eric Blake e...@byu.net -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkoatHoACgkQ84KuGfSFAYAxRwCgmFry8vgHKIsWvam/KP5vDAHW lBwAoMoX0J3Q3ZOjXiKCf0DAJd3O0p+k =LdA6 -----END PGP SIGNATURE----- _______________________________________________ Bug-coreutils mailing list Bug-coreutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-coreutils