cvs commit: src/bin/ls cmp.c extern.h ls.1 ls.c util.c

Bruce Evans bde at zeta.org.au
Sat Jun 4 04:16:49 PDT 2005


On Sat, 4 Jun 2005, Mathieu Arnold wrote:

> +-le 04/06/2005 01:17 +1000, Tim Robbins écrivait :
> | On Fri, Jun 03, 2005 at 11:05:59AM +0000, Dima Dorfman wrote:
> |> dd          2005-06-03 11:05:58 UTC
> |>
> |>   FreeBSD src repository
> |>
> |>   Modified files:
> |>     bin/ls               cmp.c extern.h ls.1 ls.c util.c
> |>   Log:
> |>   Add the -S option to sort files by size. NetBSD and OpenBSD already
> |>   have this option with identical semantics (sorting large files first).
> |>   -r can be used to reverse the sort if that is desired.
> |
> | How is this different from |sort -k5,5nr?
>
> Works only if you use "-l".

Use -l then:

     ls -l | sort -k5,5nr | awk '!/^total/ {print $9}'

This shows another bug: the "totals" line gets in the way for filters
simpler than the above and is documented to not be printed (for ls -l)
unless the output is to a terminal but it is actually printed independently
of the output device.  ls -s is documented to print totals like ls -l
but works as documented for non-terminals despite the code that prints
it being identical.

     ls -CS             # no easy way to do this with a filter but who cares

Bruce


More information about the cvs-src mailing list