>> 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.
-- * The Digital Hermit http://www.digitalhermit.com * Unix and Linux Solutions kwan@digitalhermit.com ----------------------------------------------------------------------- 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:56:56 EDT