Scott Klement wrote:
As was pointed out /six days ago/, now... you could easily do this:
ls -al | sort +4 -r
This code will work on an Unix system I'm aware of.
to get the directory sorted the way you want it. Or, if you can't stand
typing that much, you could type this:
alias lsz="ls -al | sort +4 -r"
(You could put that into a script that's run when you start QShell so
you don't have to type it each time) now whenever you like, you can sort
by size by typing:
lsz
I really think this discussion is making a mountain out of a molehill.
It was a problem that was SOOOO easy to solve. I'm having a tough time
with this thread.
Scott: You're having a tough time with this thread? Let me try to
explain it one more time:
First, note that "ls -S' is supported on Linux and the BSD unixes. It
does not seem to be supported on the System V derived Unixes. Based on
relative popularity of the various Unix variants, I estimate that at
least 95% of Unix systems (including GNU) support "ls -S". (And I think
I'm being generous to the commercial Unixes.)
Scott, you know the history of Unix. You know how well the commercial
vendors got along. They all claimed Posix compatibility. But what really
matters is not compatibility to some standard, but rather
interoperability. Consider the story behind Samba. Jeremy Allison and
others on the Samba team have done one heck of a job in achieving
interoperability, in spite of roadblocks thrown up by vendors. (The
story of how Allison exposed the lies made by a MS executive while under
oath in a European court is legend!)
But back to Unix. While the commercial vendors worked in their own
separate niches, GNU and Linux came along and changed the rules of the
game. For the commercial vendors, claiming Posix compliance was no
longer good enough. They had to also add Linux compatibility (or
affinity) to their product summary sheets.
My point is simply that GNU has usurped Posix in terms of defining what
a "Unix" system is.
Second, (and I should have raised this point much earlier in this
thread) let's say you want to be compatible across all Unixes when
wanting to sort a directory by size. Sorry, but "ls -al | sort +4 -r"
doesn't cut it. The "+" option on sort is considered obsolete under
Posix, and doesn't work on GNU. The portable way to express what you
want is "ls -al |sort -k5,5 -rn".
Cheers! Hans
As an Amazon Associate we earn from qualifying purchases.