On Fri, 16 Dec 2005, Kwan Lowe wrote:
> >> ls |xargs du -sk|sort -n|cut -f2|xargs du -sh
> >>
> >> It does a two-pass display. First, grab the output in kilobytes, then
> >> sort by size. Pass this output to 'du -sh' but this time show the
> >> human-readable format.
> >
> > Works on $PWD. What if I want to look at dirs elsewhere, or if they're
> > not all in the same place? I don't know a satisfactory method of
> > passing info into xargs. There's "--replace", but apparently I don't
> > know how to use it.
>
> You can substitute any ls command. For example:
>
> ls -1QFd /tmp/* /etc/*|grep /$ |xargs du -sk|sort -n|cut -f2 |xargs du -sh
>
> The above will do a listing in /tmp and etc, one line per entry, quoted,
> with folders marked with a "/" at the end. This is passed to grep, and
> filtered for folders. Then it just does the same two-pass sort.
>
> You can automate it in various ways, but the general idea is to pass a
> pre-sorted list to du with a single directory entry at a time.
>
> Actually, it could be done in awk (at least a portion). Use awk to sort,
> convert K to M if necessary, then output.
OK, I see. Thanks. I took out the grep, as I want to see things besides
directories. Then your pipeline is: ls | other stuff | xargs du. Mine is
du | other stuff | while read. I wonder which is faster, "ls -Q" and
"xargs" or a "while read" loop. (With "while read", I don't have to worry
about _one_ space. It's only longer runs that get squished into one. That
and single quotes (I think).) I'd guess that ' outnumbers " in filenames...
-- "Never go off on tangents, which are lines that intersect a curve at only one point and were discovered by Euclid, who lived in the 6th century, which was an era dominated by the Goths, who lived in what we now know as Poland." - Unknown from Nov. 1998 issue of Infosystems Executive.----------------------------------------------------------------------- This list is provided as an unmoderated internet service by Networked Knowledge Systems (NKS). Views and opinions expressed in messages posted are those of the author and do not necessarily reflect the official policy or position of NKS or any of its employees.
This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 19:57:03 EDT