[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: Re: sort's -k flag is buggy when M is also passed
From: "Michael D. Setzer II" <mikes () guam ! net>
Date: 2022-06-29 17:37:08
Message-ID: 62BC8DC4.31286.B8AD8E5 () mikes ! guam ! net
[Download RAW message or body]
On 29 Jun 2022 at 10:18, Dennis Chen wrote:
Date sent: Wed, 29 Jun 2022 10:18:10 -0700
Copies to: Subject: Re: sort's -k flag is buggy
when M is also passed
From: "Dennis Chen" <dchen@dennisc.net>
To: <mikes@guam.net>,
<busybox@busybox.net>
> > Had to use -e to have it insert new line.
>
> FWIW, I was able to get your tests to work without -e. (Alpine, busybox 1.35.0)
>
> > Looking at sort.c in busybox seems that
> > static char key_separator; is just defined, but not
> > assigned a default value?
> > Don't know if this might resolve issue?
> > static char key_separator=' ';
>
> Using -t ' ' might work for some cases, but consider
> abc March 3
> de April 2
> This example is a little contrived, but you might easily see something
> like this in the real world (think logfiles).
Good point think the regular sort talks about the
separator been change from blank non-blank, and that
would ge a little more of a issue.
I had modified the sort.c with the =' '; and it seemed to
work. For you issue I inserted a tr -s ' ' that would convert
multiple spaces to a single space. If added spaces before
number would need to change the 2 to 3 I believe.
echo -e "3 March\n2 April\n1 Jan\n5 Feb\n6 Dec\n8
Oct\n7 Jul\n6 Jun\n8 Aug\n15 May\n11 Nov\n9 Sep" | tr
-s ' ' |./busybox sort -k2M
1 Jan
5 Feb
3 March
2 April
15 May
6 Jun
7 Jul
8 Aug
9 Sep
8 Oct
11 Nov
6 Dec
echo -e " 3 March\n 2 April\n 1 Jan\n 5 Feb\n 6
Dec\n 8 Oct\n 7 Jul\n 6 Jun\n 8 Aug\n 15 May\n 11
Nov\n 9 Sep" | tr -s ' ' |./busybox sort -k3M
1 Jan
5 Feb
3 March
2 April
15 May
6 Jun
7 Jul
8 Aug
9 Sep
8 Oct
11 Nov
6 Dec
+------------------------------------------------------------+
Michael D. Setzer II - Computer Science Instructor
(Retired)
mailto:mikes@guam.net
mailto:msetzerii@gmail.com
Guam - Where America's Day Begins
G4L Disk Imaging Project maintainer
http://sourceforge.net/projects/g4l/
+------------------------------------------------------------+
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic