Hi there,
From a bit of brief experimentation, it seems that the "ls" command
supports two options that would accomplish what you wanted.
"-S" Sorts descendingly by size.
"-h" Shows size in human readable format (but it looks like you
already knew that one).
So together, "ls -lhS" will do the job. I cannot confirm or deny that
this will work on Solaris or OS X, as I don't have them available to
test. But I do know that both Solaris and OS X use the "ls" command
for directory listing, so I have a strong suspicion that this will
work.
I don't consider this much information to give up, so if there is
anything else I can help you find out, let me know. |
Clarification of Answer by
passive-ga
on
07 May 2004 11:36 PDT
topbanana is correct, Solaris 8 accepts neither "-h" nor "-S".
Solaris 9 seems to accept "-h".
The shortest thing I found that will do sorting by size under solaris is:
ls -al | sort -n -r --key=4,5 | more
Found at:
http://www.cgd.ucar.edu/gds/thibaud/UNIX-tips/Tips/ls-ps.html
It's hardly concise, and it's still not human readable.
Under Solaris 9, you could add "-h" in to that, but sort doesn't
recognize human readable, so the sorting would not be particularily
good.
ls -ahl | sort -n -r --key=4,5 | more
|
Request for Answer Clarification by
lostandfound-ga
on
07 May 2004 12:22 PDT
My apology... I meant to include that it should recursively list all
files in the subdirectories of the partition or directory that I
specify.
|
Clarification of Answer by
passive-ga
on
07 May 2004 12:46 PDT
Well, there is another flag that provides that:
"-R" Recursively lists subdirectories.
This works by displaying the current directory, then each
subdirectory. This means the sorting is broken up by directory, so a
large file in a subdirectory will be displayed below a small file in a
parent directory.
This should work on Solaris as well.
Will this accomplish what you want, or do you want a sorted list that
includes everything in a single list?
ls -ShlR
|
Request for Answer Clarification by
lostandfound-ga
on
07 May 2004 13:29 PDT
I really need a single sorted list. If a filesystem is nearly full, I
need a quick means of determining the largest files. Seperate lists
for each directory would be unmanagable if there are a lot of
directories.
|
Clarification of Answer by
passive-ga
on
07 May 2004 18:11 PDT
That's what I figured.
The following, though not perfectly concise, should do what you need.
du -a | sort -n -r | more
use "q" to quit "more"
It doesn't accomplish the human readability part, solely because
"sort" doesn't understand it. As it is, it's fairly easy to tell who
the largest files are.
I could probably figure out a way to get it human readable, but it
would be much longer than this, and not easy to remember.
|