[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RFC: add'l 'sort -n' options
From: |
Matthew Woehlke |
Subject: |
RFC: add'l 'sort -n' options |
Date: |
Fri, 03 Nov 2006 09:55:25 -0600 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.7) Gecko/20060909 Thunderbird/1.5.0.7 Mnenhy/0.7.4.0 |
I was thinking about some additional ways 'sort -n' might work. I'm not
asking for someone to do these (I was thinking about doing some myself);
just looking for comment on what other people think about the possibility.
The new option would be:
'-N _options_, --numeric-sort=_options_'
...and would imply '-n'.
(note that means an overload of '--numeric-sort', i.e. without the '='
would just be '-n' as it is now).
_options_ would be one or more letters:
'f': equivalent to '-g/--general-numeric-sort', i.e. convert numbers
with strtod.
'a': convert numbers with strtol(,0) (i.e. automatically recognize
'0x<num>' (hex), '0<num>' (octal).
'o': all numbers are octal, i.e. strtol(,8)
'x': all numbers are hexadecimal, i.e. strtol(,16)
'r': recursive; when comparing two strings, discard leading matches and
then compare according to numeric rules. This would allow correct
sorting of e.g. 'x.y.z-pl' (version/patch level), 'yyyy.mm.dd' (dates,
where the '.' can be any separator), etc. Possible candidate for '-R'
and long-opt.
'h': numbers are 'human-readable', i.e. '<num>[kK]
is 1024*<num>, similar with [mM], [gG], [tT]. Possible candidate for
'-H'/'-h' and long-opt.
'd': use 1000 instead of 1024 for 'h' (above).
'f', 'x', 'o', 'a' are mutually exclusive.
...and in light of 'o', 'x', perhaps '-B <num>, --numeric-base <num>'
would be in order?
I'm very open to suggestion on this; the objectives are a: to parse 'du
-h' output, and b: to implement the functionality of 'r'. I'm not
particularly attached to any specific means of achieving this.
--
Matthew
"I don't question your existence -- God" (seen on a church billboard)
- RFC: add'l 'sort -n' options,
Matthew Woehlke <=
- Re: RFC: add'l 'sort -n' options, Paul Eggert, 2006/11/04
- Re: RFC: add'l 'sort -n' options, Matthew Woehlke, 2006/11/06
- Re: RFC: add'l 'sort -n' options, Paul Eggert, 2006/11/06
- Re: RFC: add'l 'sort -n' options, Matthew Woehlke, 2006/11/06
- Re: RFC: add'l 'sort -n' options, Paul Eggert, 2006/11/06
- Re: RFC: add'l 'sort -n' options, Matthew Woehlke, 2006/11/06
- Re: RFC: add'l 'sort -n' options, Paul Eggert, 2006/11/06
- Re: RFC: add'l 'sort -n' options, Matthew Woehlke, 2006/11/06