5/7 How do I make ls sort files by size like -t for time? thx
\_ From man ls:
The following is how to do an ls listing sorted by size
(and shows why ls does not need a separate option for this):
ls -l | sort -n +4
\_ use Linux, it's -S
\_ I want to do this on soda!
\_ download gnu fileutils, compile, presto.
\- ls -ls | sort -n[r] --psb
\_ ls -ls | sort -n[r]
sort: No match.
\- dont actually type the [], you doofus --psb
\_ ls -l | sort +4 is more general.
\- it's more fragile. ls -s always makes the sort field
first. otherwise the field can depend on whether the
group owner is listed etc ... varies by ls flavor,
ls aliases etc --psb
\_ well, I meant since it depends on block size it
would fail by default for tiny files.
\- fair enough, but really arnet you just looking
for the biggest file 95% of the time. --psb
\_ Add a -n for good measure. Not all platforms will
detect an all numeric column, so "sort -n +4"
\_ ok, but he said "want to do this on soda!" :)
frankly though I think the man page is stupid and
it should be an ls option for convenience. they
have the other sorting functionality.
\_ They have sorting for time becuase sorting human
readable dates is difficult with other default
command line tools. Sorting file size is easy.
This is the UNIX way. many modular pieces you
can piece together to do what you want. Linux
makes you weak. --scotsman
\_ it's a bunch of extra characters to type for
a basic, common desire that could very easily
just be in ls where normal people expect. (hey,
why should sort have a field option anyway? you
can just manipulate lines using 'cut' etc. It's
the way real men do it.)
\_ don't be a doofus--it's not like FreeBSD
"ls" is "pure" (color "ls" doesn't make you
weak, but sorting on size does?) -tom
\_ I wasn't talking about purity. And I guess
it wasn't clear that I was being facetious.
But the point stands that to pull sort into
ls with yet another command line option
makes ls more tedious to remember how to use
and postpones the newer user's learning how
to use sort. And who uses color ls?
--scotsman
\_ how is it more tedious? If you don't
want to use -S, pipe it through sort
instead. -tom
\_ I guess I'm just sick of interviewing
IT drones who can't write a decent
command line.. --scotsman
\- how about adding a du flag that
just means du all the directories
under here but not the files.
how about another du flag that
is directories only in size
order. and another that sorts
based on number of files rather
than cumul size.. --psb
\_ Ah yes, I forgot; the only
"official" command-line options
are the ones that FreeBSD has
adopted. Therefore it's OK
to use "find -delete", but not
"ls -S" -tom
\- pure is BSD 4.3 --psb
\_ color ls is the best thing since linux!
just like color monitor is the best thing
since monochrome green terminals.
\_ Once you begin to appreciate color ls, you
will never go back, like a lot of things.
\- dired >> ls --psb
\_ using sort -n +5 gets rid of the color, oh fuck, fuck!!
\_ If you are using a terminal with black background, try
LSCOLORS=BxDxFxdxCxdxdxBxBxBxBx and do ls -G
\_ Cool, ls -lG / looks nice! |