coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Enhancement to SORT command.


From: Carl Edquist
Subject: Re: Enhancement to SORT command.
Date: Mon, 20 Sep 2021 13:09:47 -0500 (CDT)
User-agent: Alpine 2.23.2 (DEB 496 2020-07-19)

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.






reply via email to

[Prev in Thread] Current Thread [Next in Thread]