[prev in list] [next in list] [prev in thread] [next in thread] 

List:       coreutils
Subject:    Re: Enhancement to SORT command.
From:       Carl Edquist <edquist () cs ! wisc ! edu>
Date:       2021-09-20 18:09:47
Message-ID: 62592e5-50c5-50db-3772-79e34aecb28c () cs ! wisc ! edu
[Download RAW message or body]

> Works great with, eg, 'du -sh * | sort -h'

Or, well, if you want to be more careful about it,

shopt -s dotglob
du -sh0 -- * | sort -hz | tr '\0\n' '\n?'


On Mon, 20 Sep 2021, Carl Edquist wrote:

> I think 'sort -h' does just that, though for your input you'll need to remove 
> the spaces between the numeric part and the units.
>
> Eg:
>
> $ (  tr -d ' ' | sort -h ) << EOF
>>  100.0 Kb
>>  303 Mb
>>  4.01 Gb
>>  20 Mb
>>  EOF
> 100.0Kb
> 20Mb
> 303Mb
> 4.01Gb
>
> Works great with, eg, 'du -sh * | sort -h'
>
> Carl
>
> On Mon, 20 Sep 2021, mm1miq.d@gmail.com wrote:
>
>>  Hello,
>>
>>  The SORT command in GNU coreutils does not have a sort by DATA SIZE
>>  parameter.
>>
>>  for example, to sort:-
>>  -----------
>>  100.0 Kb
>>  303 Mb
>>  4.01 Gb
>>  20 Mb
>>  -----------
>>  sorts output will be:-
>>  -----------
>>  303 Mb
>>  100.0 Kb
>>  20 Mb
>>  4.01 Gb
>>  -----------
>>  It would be nice if thier was a parameter that sorted by size so the
>>  output
>>  would be 100.0 Kb, 20 Mb, 303 Mb, 4.01 Gb
>>
>>  Would be great if such a parameter was added.
>>
>>  Regards.
>> 
>
>


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic