Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Simulations are like miniskirts, they show a lot and hide the essentials. -- Hubert Kirrman


devel / comp.unix.shell / Sort the data according to the date including the abbreviation of English months.

SubjectAuthor
* Sort the data according to the date including the abbreviation ofhongy...@gmail.com
+* Re: Sort the data according to the date including the abbreviation of English Percival John Hackworth
|`- Re: Sort the data according to the date including the abbreviation ofJanis Papanagnou
+* Re: Sort the data according to the date including the abbreviation ofJanis Papanagnou
|`* Re: Sort the data according to the date including the abbreviation ofhongy...@gmail.com
| +* Re: Sort the data according to the date including the abbreviation of English moKees Nuyt
| |`* Re: Sort the data according to the date including the abbreviation ofhongy...@gmail.com
| | `* Re: Sort the data according to the date including the abbreviation ofEd Morton
| |  `* Re: Sort the data according to the date including the abbreviation of English moBen
| |   +* Re: Sort the data according to the date including the abbreviation ofChris Elvidge
| |   |`- Re: Sort the data according to the date including the abbreviation of English moBen
| |   `* Re: Sort the data according to the date including the abbreviation of English moSpiros Bousbouras
| |    `- Re: Sort the data according to the date including the abbreviation of English moBen
| +- Re: Sort the data according to the date including the abbreviation ofRichard Harnden
| `* Re: Sort the data according to the date including the abbreviation ofJanis Papanagnou
|  `* Re: Sort the data according to the date including the abbreviation ofChris Elvidge
|   `- Re: Sort the data according to the date including the abbreviation ofJanis Papanagnou
+* Re: Sort the data according to the date including the abbreviation ofmarrgol
|+- Re: Sort the data according to the date including the abbreviation ofhongy...@gmail.com
|`- Re: Sort the data according to the date including the abbreviation ofhongy...@gmail.com
`- Re: Sort the data according to the date including the abbreviation ofKenny McCormack

1
Sort the data according to the date including the abbreviation of English months.

<b57b47bd-f1ad-4af7-95da-d86be093e97fn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5242&group=comp.unix.shell#5242

  copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:a05:620a:44ca:b0:69e:b239:5f48 with SMTP id y10-20020a05620a44ca00b0069eb2395f48mr5899971qkp.746.1650423005172;
Tue, 19 Apr 2022 19:50:05 -0700 (PDT)
X-Received: by 2002:a37:6947:0:b0:69e:b41d:c9e8 with SMTP id
e68-20020a376947000000b0069eb41dc9e8mr5927210qkc.430.1650423005045; Tue, 19
Apr 2022 19:50:05 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Tue, 19 Apr 2022 19:50:04 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=203.175.13.141; posting-account=kF0ZaAoAAACPbiK5gldhAyX5qTd3krV2
NNTP-Posting-Host: 203.175.13.141
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <b57b47bd-f1ad-4af7-95da-d86be093e97fn@googlegroups.com>
Subject: Sort the data according to the date including the abbreviation of
English months.
From: hongyi.z...@gmail.com (hongy...@gmail.com)
Injection-Date: Wed, 20 Apr 2022 02:50:05 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 19
 by: hongy...@gmail.com - Wed, 20 Apr 2022 02:50 UTC

My data includes the following data formats in each row:

$ cat 1111
Jul 23 2021
Apr 30 2019
Jan 2 2022
Oct 24 2004

I want to sort them according to the date, and tried with sort as follows:

$ sort -k1 < 1111
Apr 30 2019
Jan 2 2022
Jul 23 2021
Oct 24 2004

Obviously, this doesn't work as expected. Any hints for dealing with this problem?

Regards,
HZ

Re: Sort the data according to the date including the abbreviation of English months.

<jc9cvuFgmkfU1@mid.individual.net>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5243&group=comp.unix.shell#5243

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: pjh...@nanoworks.com (Percival John Hackworth)
Newsgroups: comp.unix.shell
Subject: Re: Sort the data according to the date including the abbreviation of English months.
Date: 20 Apr 2022 03:29:02 GMT
Lines: 35
Message-ID: <jc9cvuFgmkfU1@mid.individual.net>
References: <b57b47bd-f1ad-4af7-95da-d86be093e97fn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=fixed
Content-Transfer-Encoding: 8bit
X-Trace: individual.net RwBAUb2Lsiz80ElW5OQ3BQNM2gCdn5sJZwqsNy7ul9SsafRNpq
Cancel-Lock: sha1:GxAUQddBYcRBcpAgHr5A365Dj7Y=
User-Agent: Usenapp for MacOS
X-Usenapp: v1.19/l - Full License
 by: Percival John Hackwo - Wed, 20 Apr 2022 03:29 UTC

On 19-Apr-2022 at 7:50:04PM PDT, "hongyi.zhao@gmail.com"
<hongyi.zhao@gmail.com> wrote:

> My data includes the following data formats in each row:
>
> $ cat 1111
> Jul 23 2021
> Apr 30 2019
> Jan 2 2022
> Oct 24 2004
>
> I want to sort them according to the date, and tried with sort as follows:
>
> $ sort -k1 <1111> Apr 30 2019
> Jan 2 2022
> Jul 23 2021
> Oct 24 2004
>
> Obviously, this doesn't work as expected. Any hints for dealing with this
> problem?
>
> Regards,
> HZ

Sort does have a flag to sort on month abbreviations, but you really want to
sort on the entire date which is all three fields. You'll have to add a field
that's the concatination of all three fields in the form YYYY-MM-DD where you
convert the string month into a 01-12 number, then sort on that. I don't see a
way to do this with just the shell built-ins or standard utilities. You'll
have to write a perl or python script to process this data line by line. Or
pull all the data into Excel and use it's sort columns feature. That's
probably the easiest way you'll be able to deal with this given your questions
on this forum.
--
DeeDee, don't press that button! DeeDee! NO! Dee...

Re: Sort the data according to the date including the abbreviation of English months.

<t3o2jv$qe2$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5244&group=comp.unix.shell#5244

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Sort the data according to the date including the abbreviation of
English months.
Date: Wed, 20 Apr 2022 06:36:15 +0200
Organization: A noiseless patient Spider
Lines: 36
Message-ID: <t3o2jv$qe2$1@dont-email.me>
References: <b57b47bd-f1ad-4af7-95da-d86be093e97fn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 20 Apr 2022 04:36:16 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="c2fd462b44d2e4caca7e39f3c91fa9d5";
logging-data="27074"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/7ETeY0X/P/hfuHWvTalZx"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:Ggn8WU3xSQJnIdRyKHm+5QQln+A=
In-Reply-To: <b57b47bd-f1ad-4af7-95da-d86be093e97fn@googlegroups.com>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Wed, 20 Apr 2022 04:36 UTC

On 20.04.2022 04:50, hongy...@gmail.com wrote:
> My data includes the following data formats in each row:
>
> $ cat 1111
> Jul 23 2021
> Apr 30 2019
> Jan 2 2022
> Oct 24 2004
>
> I want to sort them according to the date, and tried with sort as follows:
>
> $ sort -k1 < 1111
> Apr 30 2019
> Jan 2 2022
> Jul 23 2021
> Oct 24 2004
>
> Obviously, this doesn't work as expected. Any hints for dealing with this problem?

Generally I'd try to avoid pathological date formats in the first place
and create and use ISO-dates or convert the dates to ISO format.

Otherwise we probably need more or less clumsy workarounds, e.g. like

while read usdate
do date -d "${usdate}" "+%Y-%m-%d ${usdate}"
done <your_file | sort | cut -d\ -f2-

Janis

>
> Regards,
> HZ
>

Re: Sort the data according to the date including the abbreviation of English months.

<t3o3ap$ulv$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5245&group=comp.unix.shell#5245

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Sort the data according to the date including the abbreviation of
English months.
Date: Wed, 20 Apr 2022 06:48:24 +0200
Organization: A noiseless patient Spider
Lines: 51
Message-ID: <t3o3ap$ulv$1@dont-email.me>
References: <b57b47bd-f1ad-4af7-95da-d86be093e97fn@googlegroups.com>
<jc9cvuFgmkfU1@mid.individual.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 20 Apr 2022 04:48:25 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="c2fd462b44d2e4caca7e39f3c91fa9d5";
logging-data="31423"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/R8CFtLRWsXYG26zL/E9q5"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:PBvB0a+xewQK9LiU11aS7JrDIFo=
In-Reply-To: <jc9cvuFgmkfU1@mid.individual.net>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Wed, 20 Apr 2022 04:48 UTC

On 20.04.2022 05:29, Percival John Hackworth wrote:
> On 19-Apr-2022 at 7:50:04PM PDT, "hongyi.zhao@gmail.com"
> <hongyi.zhao@gmail.com> wrote:
>
>> My data includes the following data formats in each row:
>>
>> $ cat 1111
>> Jul 23 2021
>> Apr 30 2019
>> Jan 2 2022
>> Oct 24 2004
>>
>> I want to sort them according to the date, and tried with sort as follows:
>>
>> $ sort -k1 <1111> Apr 30 2019
>> Jan 2 2022
>> Jul 23 2021
>> Oct 24 2004
>>
>> Obviously, this doesn't work as expected. Any hints for dealing with this
>> problem?
>>
>> Regards,
>> HZ
>
> Sort does have a flag to sort on month abbreviations, but you really want to
> sort on the entire date which is all three fields. You'll have to add a field
> that's the concatination of all three fields in the form YYYY-MM-DD where you
> convert the string month into a 01-12 number, then sort on that. I don't see a
> way to do this with just the shell built-ins or standard utilities.

There are many ways to do that in shell with the Unix utilities;
I posted one in this thread.

> You'll
> have to write a perl or python script to process this data line by line.

Unnecessary.

> Or pull all the data into Excel and use it's sort columns feature. That's
> probably the easiest way you'll be able to deal with this given your questions
> on this forum.

This is about the most stupid suggestion I can think of (yet more
so in a Unix newsgroup). - Don't do any manual steps if you can
automate the task. Don't transfer data from one system to another
if it's unnecessary. Don't switch from a powerful Unix OS to a
Windows OS (or equivalent). - YMMV.

Janis

Re: Sort the data according to the date including the abbreviation of English months.

<4029fa37-4165-4217-979d-c3cad7d445a1n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5246&group=comp.unix.shell#5246

  copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:a05:622a:1012:b0:2e1:e7f3:5c89 with SMTP id d18-20020a05622a101200b002e1e7f35c89mr12793113qte.550.1650438363481;
Wed, 20 Apr 2022 00:06:03 -0700 (PDT)
X-Received: by 2002:a05:622a:487:b0:2f2:4a6:6a43 with SMTP id
p7-20020a05622a048700b002f204a66a43mr7337505qtx.63.1650438363334; Wed, 20 Apr
2022 00:06:03 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Wed, 20 Apr 2022 00:06:03 -0700 (PDT)
In-Reply-To: <t3o2jv$qe2$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=51.79.193.154; posting-account=kF0ZaAoAAACPbiK5gldhAyX5qTd3krV2
NNTP-Posting-Host: 51.79.193.154
References: <b57b47bd-f1ad-4af7-95da-d86be093e97fn@googlegroups.com> <t3o2jv$qe2$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <4029fa37-4165-4217-979d-c3cad7d445a1n@googlegroups.com>
Subject: Re: Sort the data according to the date including the abbreviation of
English months.
From: hongyi.z...@gmail.com (hongy...@gmail.com)
Injection-Date: Wed, 20 Apr 2022 07:06:03 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 39
 by: hongy...@gmail.com - Wed, 20 Apr 2022 07:06 UTC

On Wednesday, April 20, 2022 at 12:36:21 PM UTC+8, Janis Papanagnou wrote:
> On 20.04.2022 04:50, hongy...@gmail.com wrote:
> > My data includes the following data formats in each row:
> >
> > $ cat 1111
> > Jul 23 2021
> > Apr 30 2019
> > Jan 2 2022
> > Oct 24 2004
> >
> > I want to sort them according to the date, and tried with sort as follows:
> >
> > $ sort -k1 < 1111
> > Apr 30 2019
> > Jan 2 2022
> > Jul 23 2021
> > Oct 24 2004
> >
> > Obviously, this doesn't work as expected. Any hints for dealing with this problem?
> Generally I'd try to avoid pathological date formats in the first place
> and create and use ISO-dates or convert the dates to ISO format.
>
> Otherwise we probably need more or less clumsy workarounds, e.g. like
>
> while read usdate
> do date -d "${usdate}" "+%Y-%m-%d ${usdate}"
> done <your_file | sort | cut -d\ -f2-

$ cat usdate
Jul 23 2021
Apr 30 2019
Jan 2 2022
Oct 24 2004

$ while read usdate
do date -d "${usdate}" "+%Y-%m-%d ${usdate}"
done <usdate | sort | cut -d\ -f2-
cut: the delimiter must be a single character
Try 'cut --help' for more information.

Re: Sort the data according to the date including the abbreviation of English months.

<625fd8e0$0$481$65785112@news.neostrada.pl>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5247&group=comp.unix.shell#5247

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!newsfeed.neostrada.pl!unt-exc-02.news.neostrada.pl!unt-spo-a-01.news.neostrada.pl!news.neostrada.pl.POSTED!not-for-mail
Subject: Re: Sort the data according to the date including the abbreviation of
English months.
Newsgroups: comp.unix.shell
References: <b57b47bd-f1ad-4af7-95da-d86be093e97fn@googlegroups.com>
From: marr...@address.invalid (marrgol)
Date: Wed, 20 Apr 2022 11:56:48 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
MIME-Version: 1.0
In-Reply-To: <b57b47bd-f1ad-4af7-95da-d86be093e97fn@googlegroups.com>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
Lines: 29
Message-ID: <625fd8e0$0$481$65785112@news.neostrada.pl>
Organization: Telekomunikacja Polska
NNTP-Posting-Host: 176.111.237.144
X-Trace: 1650448608 unt-rea-b-01.news.neostrada.pl 481 176.111.237.144:48126
X-Complaints-To: abuse@news.neostrada.pl
X-Received-Bytes: 1727
 by: marrgol - Wed, 20 Apr 2022 09:56 UTC

On 20/04/2022 at 04.50, hongy...@gmail.com wrote:
> My data includes the following data formats in each row:
>
> $ cat 1111
> Jul 23 2021
> Apr 30 2019
> Jan 2 2022
> Oct 24 2004
>
> I want to sort them according to the date, and tried with sort as follows:
>
> $ sort -k1 < 1111
> Apr 30 2019
> Jan 2 2022
> Jul 23 2021
> Oct 24 2004
>
> Obviously, this doesn't work as expected. Any hints for dealing with this problem?

Yeah, the same hint you are always given and never take:
read the man page and use the information from there.

For dates in the format shown above this should work:

$ sort -b -k3n,3 -k1M,1 -k2n,2 < 1111

--
mrg

Re: Sort the data according to the date including the abbreviation of English months.

<775d6d97-20ba-4998-91fc-072c5bb28c2en@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5248&group=comp.unix.shell#5248

  copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:a05:622a:15cb:b0:2f2:681:7d06 with SMTP id d11-20020a05622a15cb00b002f206817d06mr6931378qty.386.1650451213581;
Wed, 20 Apr 2022 03:40:13 -0700 (PDT)
X-Received: by 2002:a05:620a:17a8:b0:69e:dde8:19f7 with SMTP id
ay40-20020a05620a17a800b0069edde819f7mr747127qkb.736.1650451213413; Wed, 20
Apr 2022 03:40:13 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Wed, 20 Apr 2022 03:40:13 -0700 (PDT)
In-Reply-To: <625fd8e0$0$481$65785112@news.neostrada.pl>
Injection-Info: google-groups.googlegroups.com; posting-host=165.22.54.254; posting-account=kF0ZaAoAAACPbiK5gldhAyX5qTd3krV2
NNTP-Posting-Host: 165.22.54.254
References: <b57b47bd-f1ad-4af7-95da-d86be093e97fn@googlegroups.com> <625fd8e0$0$481$65785112@news.neostrada.pl>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <775d6d97-20ba-4998-91fc-072c5bb28c2en@googlegroups.com>
Subject: Re: Sort the data according to the date including the abbreviation of
English months.
From: hongyi.z...@gmail.com (hongy...@gmail.com)
Injection-Date: Wed, 20 Apr 2022 10:40:13 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 49
 by: hongy...@gmail.com - Wed, 20 Apr 2022 10:40 UTC

On Wednesday, April 20, 2022 at 5:56:54 PM UTC+8, marrgol wrote:
> On 20/04/2022 at 04.50, hongy...@gmail.com wrote:
> > My data includes the following data formats in each row:
> >
> > $ cat 1111
> > Jul 23 2021
> > Apr 30 2019
> > Jan 2 2022
> > Oct 24 2004
> >
> > I want to sort them according to the date, and tried with sort as follows:
> >
> > $ sort -k1 < 1111
> > Apr 30 2019
> > Jan 2 2022
> > Jul 23 2021
> > Oct 24 2004
> >
> > Obviously, this doesn't work as expected. Any hints for dealing with this problem?
> Yeah, the same hint you are always given and never take:
> read the man page and use the information from there.
>
> For dates in the format shown above this should work:
>
> $ sort -b -k3n,3 -k1M,1 -k2n,2 < 1111

Yes. This works as shown below:

$ cat usdate
Jul 23 2021
Apr 30 2021
Jan 2 2021
Oct 24 2021

$ sort -b -k3n,3 -k1M,1 -k2n,2 usdate
Jan 2 2021
Apr 30 2021
Jul 23 2021
Oct 24 2021

$ sort -b -k3n,3 -k1rM,1 -k2n,2 usdate
Oct 24 2021
Jul 23 2021
Apr 30 2021
Jan 2 2021

But what's the meaning of `,3` used in the `-k3n,3` and other two similar options?

Regards,
HZ

Re: Sort the data according to the date including the abbreviation of English months.

<t3oqf1$360f4$1@news.xmission.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5249&group=comp.unix.shell#5249

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gaze...@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: Re: Sort the data according to the date including the abbreviation of
English months.
Date: Wed, 20 Apr 2022 11:23:13 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <t3oqf1$360f4$1@news.xmission.com>
References: <b57b47bd-f1ad-4af7-95da-d86be093e97fn@googlegroups.com>
Injection-Date: Wed, 20 Apr 2022 11:23:13 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="3342820"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Wed, 20 Apr 2022 11:23 UTC

In article <b57b47bd-f1ad-4af7-95da-d86be093e97fn@googlegroups.com>,
hongy...@gmail.com <hongyi.zhao@gmail.com> wrote:
>My data includes the following data formats in each row:
>
>$ cat 1111
>Jul 23 2021
>Apr 30 2019
>Jan 2 2022
>Oct 24 2004
>
>I want to sort them according to the date, and tried with sort as follows:

(untested)

#!/usr/bin/gawk
BEGIN {
split("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec",T)
for (i in T) months[T[i]] = i
}
{ x[mktime[$3 " " months[$1] " " $2 " 0 0 0"] = $0 }
END {
n = asort(x,x,"@val_num_asc")
for (i=1; i<=n; i++) print x[i]
}

P.S. More to type than the "sort(1)" based idea, but a lot more clear
(once you understand GAWK - and if you don't already, you should make it
your top priority to do so). I totally dislike sort(1) - freaky ugly
syntax!

--
People who want to share their religious views with you
almost never want you to share yours with them. -- Dave Barry

Re: Sort the data according to the date including the abbreviation of English months.

<tdsv5hh5cd9ckjrv5qcjdgk6a8q7o5jmni@dim53.demon.nl>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5250&group=comp.unix.shell#5250

  copy link   Newsgroups: comp.unix.shell
From: k.n...@nospam.demon.nl (Kees Nuyt)
Newsgroups: comp.unix.shell
Subject: Re: Sort the data according to the date including the abbreviation of English months.
Date: Wed, 20 Apr 2022 13:44:29 +0200
Reply-To: k.nuyt@nospam.demon.nl
Message-ID: <tdsv5hh5cd9ckjrv5qcjdgk6a8q7o5jmni@dim53.demon.nl>
References: <b57b47bd-f1ad-4af7-95da-d86be093e97fn@googlegroups.com> <t3o2jv$qe2$1@dont-email.me> <4029fa37-4165-4217-979d-c3cad7d445a1n@googlegroups.com>
User-Agent: ForteAgent/7.10.32.1214
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Organization: KPN B.V.
Path: i2pn2.org!i2pn.org!aioe.org!feeder1.feed.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr1.eu1.usenetexpress.com!94.232.112.245.MISMATCH!abe005.abavia.com!abp003.abavia.com!news.kpn.nl!not-for-mail
Lines: 14
Injection-Date: Wed, 20 Apr 2022 13:44:29 +0200
Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com"
 by: Kees Nuyt - Wed, 20 Apr 2022 11:44 UTC

On Wed, 20 Apr 2022 00:06:03 -0700 (PDT), "hongy...@gmail.com"
<hongyi.zhao@gmail.com> wrote:

> cut -d\ -f2-
> cut: the delimiter must be a single character
> Try 'cut --help' for more information.

Did you try 'man cut' ?
Did you even try to solve this yourself.
What about cut -d ' ' -f2- ?
Sigh.
--
k

Re: Sort the data according to the date including the abbreviation of English months.

<c1f564b9-9059-4967-b6e0-7fe2adad1723n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5251&group=comp.unix.shell#5251

  copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:a05:622a:147:b0:2f3:3f7f:602e with SMTP id v7-20020a05622a014700b002f33f7f602emr4487592qtw.439.1650499664825;
Wed, 20 Apr 2022 17:07:44 -0700 (PDT)
X-Received: by 2002:a05:6214:27c9:b0:446:5771:397b with SMTP id
ge9-20020a05621427c900b004465771397bmr13194373qvb.75.1650499664649; Wed, 20
Apr 2022 17:07:44 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Wed, 20 Apr 2022 17:07:44 -0700 (PDT)
In-Reply-To: <tdsv5hh5cd9ckjrv5qcjdgk6a8q7o5jmni@dim53.demon.nl>
Injection-Info: google-groups.googlegroups.com; posting-host=165.22.54.254; posting-account=kF0ZaAoAAACPbiK5gldhAyX5qTd3krV2
NNTP-Posting-Host: 165.22.54.254
References: <b57b47bd-f1ad-4af7-95da-d86be093e97fn@googlegroups.com>
<t3o2jv$qe2$1@dont-email.me> <4029fa37-4165-4217-979d-c3cad7d445a1n@googlegroups.com>
<tdsv5hh5cd9ckjrv5qcjdgk6a8q7o5jmni@dim53.demon.nl>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <c1f564b9-9059-4967-b6e0-7fe2adad1723n@googlegroups.com>
Subject: Re: Sort the data according to the date including the abbreviation of
English months.
From: hongyi.z...@gmail.com (hongy...@gmail.com)
Injection-Date: Thu, 21 Apr 2022 00:07:44 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 12
 by: hongy...@gmail.com - Thu, 21 Apr 2022 00:07 UTC

On Wednesday, April 20, 2022 at 7:44:35 PM UTC+8, Kees Nuyt wrote:
> On Wed, 20 Apr 2022 00:06:03 -0700 (PDT), "hongy...@gmail.com"
> <hongy...@gmail.com> wrote:
>
> > cut -d\ -f2-
> > cut: the delimiter must be a single character
> > Try 'cut --help' for more information.
> Did you try 'man cut' ?
> Did you even try to solve this yourself.
> What about cut -d ' ' -f2- ?

But this code snippet is given by Janis Papanagnou, an expert in this group. So I don't know how he can write like this.

Re: Sort the data according to the date including the abbreviation of English months.

<t3qejc$qgk$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5252&group=comp.unix.shell#5252

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: mortons...@gmail.com (Ed Morton)
Newsgroups: comp.unix.shell
Subject: Re: Sort the data according to the date including the abbreviation of
English months.
Date: Wed, 20 Apr 2022 21:12:59 -0500
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <t3qejc$qgk$1@dont-email.me>
References: <b57b47bd-f1ad-4af7-95da-d86be093e97fn@googlegroups.com>
<t3o2jv$qe2$1@dont-email.me>
<4029fa37-4165-4217-979d-c3cad7d445a1n@googlegroups.com>
<tdsv5hh5cd9ckjrv5qcjdgk6a8q7o5jmni@dim53.demon.nl>
<c1f564b9-9059-4967-b6e0-7fe2adad1723n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 21 Apr 2022 02:13:00 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="9ded9dba6cd9b6df21f35137e4f9d994";
logging-data="27156"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX181dIvbGwxDobv/y1TDb38b"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.8.1
Cancel-Lock: sha1:oppyB3Zn+VVeu2ZViliJI/J+RW8=
In-Reply-To: <c1f564b9-9059-4967-b6e0-7fe2adad1723n@googlegroups.com>
X-Antivirus-Status: Clean
Content-Language: en-US
X-Antivirus: Avast (VPS 220420-6, 4/20/2022), Outbound message
 by: Ed Morton - Thu, 21 Apr 2022 02:12 UTC

On 4/20/2022 7:07 PM, hongy...@gmail.com wrote:
> On Wednesday, April 20, 2022 at 7:44:35 PM UTC+8, Kees Nuyt wrote:
>> On Wed, 20 Apr 2022 00:06:03 -0700 (PDT), "hongy...@gmail.com"
>> <hongy...@gmail.com> wrote:
>>
>>> cut -d\ -f2-
>>> cut: the delimiter must be a single character
>>> Try 'cut --help' for more information.
>> Did you try 'man cut' ?
>> Did you even try to solve this yourself.
>> What about cut -d ' ' -f2- ?
>
> But this code snippet is given by Janis Papanagnou, an expert in this group. So I don't know how he can write like this.
>

They didn't, you copy/pasted it wrong. Take a few seconds to look at the
code Janis provided and think about the way in which the code you
executed is not the same as that and what that means to the shell
interpreting it.

Ed.

Re: Sort the data according to the date including the abbreviation of English months.

<87k0bi7mbm.fsf@bsb.me.uk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5253&group=comp.unix.shell#5253

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!news.freedyn.de!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben)
Newsgroups: comp.unix.shell
Subject: Re: Sort the data according to the date including the abbreviation of English months.
Date: Thu, 21 Apr 2022 11:38:53 +0100
Organization: A noiseless patient Spider
Lines: 35
Message-ID: <87k0bi7mbm.fsf@bsb.me.uk>
References: <b57b47bd-f1ad-4af7-95da-d86be093e97fn@googlegroups.com>
<t3o2jv$qe2$1@dont-email.me>
<4029fa37-4165-4217-979d-c3cad7d445a1n@googlegroups.com>
<tdsv5hh5cd9ckjrv5qcjdgk6a8q7o5jmni@dim53.demon.nl>
<c1f564b9-9059-4967-b6e0-7fe2adad1723n@googlegroups.com>
<t3qejc$qgk$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="0edf30fb0378872d2392a90a7cc48d20";
logging-data="21320"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+TTs+g8NXjPZewTTW4IVxREEgxTx9viQk="
Cancel-Lock: sha1:OqOw/T2ybQDrVWuDAlMQgy4a9+Y=
sha1:r4UGK4KJpAxtg8j/ws9Y+g8+QLw=
X-BSB-Auth: 1.c0c56ef39fb3c98de26c.20220421113853BST.87k0bi7mbm.fsf@bsb.me.uk
 by: Ben - Thu, 21 Apr 2022 10:38 UTC

Ed Morton <mortonspam@gmail.com> writes:

> On 4/20/2022 7:07 PM, hongy...@gmail.com wrote:
>> On Wednesday, April 20, 2022 at 7:44:35 PM UTC+8, Kees Nuyt wrote:
>>> On Wed, 20 Apr 2022 00:06:03 -0700 (PDT), "hongy...@gmail.com"
>>> <hongy...@gmail.com> wrote:
>>>
>>>> cut -d\ -f2-
>>>> cut: the delimiter must be a single character
>>>> Try 'cut --help' for more information.
>>>
>>> Did you try 'man cut' ?
>>> Did you even try to solve this yourself.
>>> What about cut -d ' ' -f2- ?
>>
>> But this code snippet is given by Janis Papanagnou, an expert in this
>> group. So I don't know how he can write like this.
>
> They didn't, you copy/pasted it wrong. Take a few seconds to look at
> the code Janis provided and think about the way in which the code you
> executed is not the same as that and what that means to the shell
> interpreting it.

It's only Hongyi Zhao's fault rather indirectly for using Google Groups.
The -d\ -f2- is correct when I view Janis's post in my newsreader, but
it has already been broken when I view it in GG. And now there's
nothing one can do but spot and correct the fault by hand. Copying the
text just copies the error GG has introduced.

GG has been going downhill for a long time (yes, hard to imagine there
was ever a hill it could go down), but now it seems that 100% correct
advice will be seen by the GG world as wrong for ever!

--
Ben.

Re: Sort the data according to the date including the abbreviation of English months.

<t3re70$db2$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5254&group=comp.unix.shell#5254

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: chr...@mshome.net (Chris Elvidge)
Newsgroups: comp.unix.shell
Subject: Re: Sort the data according to the date including the abbreviation of
English months.
Date: Thu, 21 Apr 2022 12:12:16 +0100
Organization: A noiseless patient Spider
Lines: 11
Message-ID: <t3re70$db2$1@dont-email.me>
References: <b57b47bd-f1ad-4af7-95da-d86be093e97fn@googlegroups.com>
<t3o2jv$qe2$1@dont-email.me>
<4029fa37-4165-4217-979d-c3cad7d445a1n@googlegroups.com>
<tdsv5hh5cd9ckjrv5qcjdgk6a8q7o5jmni@dim53.demon.nl>
<c1f564b9-9059-4967-b6e0-7fe2adad1723n@googlegroups.com>
<t3qejc$qgk$1@dont-email.me> <87k0bi7mbm.fsf@bsb.me.uk>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 21 Apr 2022 11:12:32 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="912cfb6521134bade0ea2e4b83e5ef2c";
logging-data="13666"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+z6SfbsfgZGzXBcWmJdWjqcPFOhZb0c90="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101
Thunderbird/52.2.1 Lightning/5.4
Cancel-Lock: sha1:PGrmvHDiBYpXA7NKntZmkWBBURU=
In-Reply-To: <87k0bi7mbm.fsf@bsb.me.uk>
Content-Language: en-GB
 by: Chris Elvidge - Thu, 21 Apr 2022 11:12 UTC

On 21/04/2022 11:38, Ben wrote:
> It's only Hongyi Zhao's fault rather indirectly for using Google Groups.
> The -d\ -f2- is correct when I view Janis's post in my newsreader, but
> it has already been broken when I view it in GG.

HTML is probably the culprit.
Multiple spaces (and tabs) are 'condensed' into one space.

--
Chris Elvidge
England

Re: Sort the data according to the date including the abbreviation of English months.

<t3re80$dir$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5255&group=comp.unix.shell#5255

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: richard....@gmail.com (Richard Harnden)
Newsgroups: comp.unix.shell
Subject: Re: Sort the data according to the date including the abbreviation of
English months.
Date: Thu, 21 Apr 2022 12:13:02 +0100
Organization: A noiseless patient Spider
Lines: 59
Message-ID: <t3re80$dir$1@dont-email.me>
References: <b57b47bd-f1ad-4af7-95da-d86be093e97fn@googlegroups.com>
<t3o2jv$qe2$1@dont-email.me>
<4029fa37-4165-4217-979d-c3cad7d445a1n@googlegroups.com>
Reply-To: nospam.harnden@gmail.com
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 21 Apr 2022 11:13:04 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="bac6794d4648aea074472a93d0c9365f";
logging-data="13915"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+ag4Q6w1iKDOtNFhyn1lojqwYOm37Oshs="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.8.0
Cancel-Lock: sha1:41SrB4UvjqcclqwRqZDivkL9AoA=
In-Reply-To: <4029fa37-4165-4217-979d-c3cad7d445a1n@googlegroups.com>
 by: Richard Harnden - Thu, 21 Apr 2022 11:13 UTC

On 20/04/2022 08:06, hongy...@gmail.com wrote:
> On Wednesday, April 20, 2022 at 12:36:21 PM UTC+8, Janis Papanagnou wrote:
>> On 20.04.2022 04:50, hongy...@gmail.com wrote:
>>> My data includes the following data formats in each row:
>>>
>>> $ cat 1111
>>> Jul 23 2021
>>> Apr 30 2019
>>> Jan 2 2022
>>> Oct 24 2004
>>>
>>> I want to sort them according to the date, and tried with sort as follows:
>>>
>>> $ sort -k1 < 1111
>>> Apr 30 2019
>>> Jan 2 2022
>>> Jul 23 2021
>>> Oct 24 2004
>>>
>>> Obviously, this doesn't work as expected. Any hints for dealing with this problem?
>> Generally I'd try to avoid pathological date formats in the first place
>> and create and use ISO-dates or convert the dates to ISO format.
>>
>> Otherwise we probably need more or less clumsy workarounds, e.g. like
>>
>> while read usdate
>> do date -d "${usdate}" "+%Y-%m-%d ${usdate}"
>> done <your_file | sort | cut -d\ -f2-
>
> $ cat usdate
> Jul 23 2021
> Apr 30 2019
> Jan 2 2022
> Oct 24 2004

"usdate" is the variable that read assignes, not your test data file.

You want:
$ cat your_file
Apr 30 2019
Jan 2 2022
Jul 23 2021
Oct 24 2004

>
> $ while read usdate
> do date -d "${usdate}" "+%Y-%m-%d ${usdate}"
> done <usdate | sort | cut -d\ -f2-
> cut: the delimiter must be a single character
> Try 'cut --help' for more information.

and:
$ while read usdate
do
date -d "${usdate}" "+%F ${usdate}"
done < your_file | sort | cut -d" " -f2-

>

Re: Sort the data according to the date including the abbreviation of English months.

<3ZE8qTuzEJKdkVLTu@bongo-ra.co>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5256&group=comp.unix.shell#5256

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: spi...@gmail.com (Spiros Bousbouras)
Newsgroups: comp.unix.shell
Subject: Re: Sort the data according to the date including the abbreviation of English months.
Date: Thu, 21 Apr 2022 13:59:33 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 29
Message-ID: <3ZE8qTuzEJKdkVLTu@bongo-ra.co>
References: <b57b47bd-f1ad-4af7-95da-d86be093e97fn@googlegroups.com> <t3o2jv$qe2$1@dont-email.me> <4029fa37-4165-4217-979d-c3cad7d445a1n@googlegroups.com>
<tdsv5hh5cd9ckjrv5qcjdgk6a8q7o5jmni@dim53.demon.nl> <c1f564b9-9059-4967-b6e0-7fe2adad1723n@googlegroups.com> <t3qejc$qgk$1@dont-email.me>
<87k0bi7mbm.fsf@bsb.me.uk>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 21 Apr 2022 13:59:33 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="c946aed392b0f4002cf40af06a3ccb49";
logging-data="28049"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1++eZ4XpeSZiLD59FQvCDF4"
Cancel-Lock: sha1:5M31ReB73hoJfm0zSPW7E9AkHxU=
In-Reply-To: <87k0bi7mbm.fsf@bsb.me.uk>
X-Organisation: Weyland-Yutani
X-Server-Commands: nowebcancel
 by: Spiros Bousbouras - Thu, 21 Apr 2022 13:59 UTC

On Thu, 21 Apr 2022 11:38:53 +0100
Ben <ben.usenet@bsb.me.uk> wrote:
> Ed Morton <mortonspam@gmail.com> writes:
>
> > On 4/20/2022 7:07 PM, hongy...@gmail.com wrote:
> >> On Wednesday, April 20, 2022 at 7:44:35 PM UTC+8, Kees Nuyt wrote:
> >>> On Wed, 20 Apr 2022 00:06:03 -0700 (PDT), "hongy...@gmail.com"
> >>> <hongy...@gmail.com> wrote:
> >>>
> >>>> cut -d\ -f2-
> >>>> cut: the delimiter must be a single character
> >>>> Try 'cut --help' for more information.
[...]

> It's only Hongyi Zhao's fault rather indirectly for using Google Groups.
> The -d\ -f2- is correct when I view Janis's post in my newsreader, but
> it has already been broken when I view it in GG. And now there's
> nothing one can do but spot and correct the fault by hand. Copying the
> text just copies the error GG has introduced.
>
> GG has been going downhill for a long time (yes, hard to imagine there
> was ever a hill it could go down), but now it seems that 100% correct
> advice will be seen by the GG world as wrong for ever!

Not necessarily for ever. If googlegroups internally stores the messages
as they came through NNTP then , when the HTML rendering bug gets fixed ,
the post (and all the others which screw up indendation) will display
correctly. On the other hand , messages which respond to a googlegroups
post through googlegroups , may end up having the mistake forever.

Re: Sort the data according to the date including the abbreviation of English months.

<87zgke5u27.fsf@bsb.me.uk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5259&group=comp.unix.shell#5259

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben)
Newsgroups: comp.unix.shell
Subject: Re: Sort the data according to the date including the abbreviation of English months.
Date: Thu, 21 Apr 2022 16:34:40 +0100
Organization: A noiseless patient Spider
Lines: 39
Message-ID: <87zgke5u27.fsf@bsb.me.uk>
References: <b57b47bd-f1ad-4af7-95da-d86be093e97fn@googlegroups.com>
<t3o2jv$qe2$1@dont-email.me>
<4029fa37-4165-4217-979d-c3cad7d445a1n@googlegroups.com>
<tdsv5hh5cd9ckjrv5qcjdgk6a8q7o5jmni@dim53.demon.nl>
<c1f564b9-9059-4967-b6e0-7fe2adad1723n@googlegroups.com>
<t3qejc$qgk$1@dont-email.me> <87k0bi7mbm.fsf@bsb.me.uk>
<3ZE8qTuzEJKdkVLTu@bongo-ra.co>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="0edf30fb0378872d2392a90a7cc48d20";
logging-data="3920"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18xWX0DOQIXTPYKgVPHycMzpE8xn5ASX1I="
Cancel-Lock: sha1:68jQUy3zgXR/IQGgQDpuFqgwsy8=
sha1:rhQdDVQHG/o23+PhSj7DHbjKOzQ=
X-BSB-Auth: 1.ea8eaa06477cbd0aad99.20220421163440BST.87zgke5u27.fsf@bsb.me.uk
 by: Ben - Thu, 21 Apr 2022 15:34 UTC

Spiros Bousbouras <spibou@gmail.com> writes:

> On Thu, 21 Apr 2022 11:38:53 +0100
> Ben <ben.usenet@bsb.me.uk> wrote:
>> Ed Morton <mortonspam@gmail.com> writes:
>>
>> > On 4/20/2022 7:07 PM, hongy...@gmail.com wrote:
>> >> On Wednesday, April 20, 2022 at 7:44:35 PM UTC+8, Kees Nuyt wrote:
>> >>> On Wed, 20 Apr 2022 00:06:03 -0700 (PDT), "hongy...@gmail.com"
>> >>> <hongy...@gmail.com> wrote:
>> >>>
>> >>>> cut -d\ -f2-
>> >>>> cut: the delimiter must be a single character
>> >>>> Try 'cut --help' for more information.
> [...]
>
>> It's only Hongyi Zhao's fault rather indirectly for using Google Groups.
>> The -d\ -f2- is correct when I view Janis's post in my newsreader, but
>> it has already been broken when I view it in GG. And now there's
>> nothing one can do but spot and correct the fault by hand. Copying the
>> text just copies the error GG has introduced.
>>
>> GG has been going downhill for a long time (yes, hard to imagine there
>> was ever a hill it could go down), but now it seems that 100% correct
>> advice will be seen by the GG world as wrong for ever!
>
> Not necessarily for ever. If googlegroups internally stores the messages
> as they came through NNTP then , when the HTML rendering bug gets fixed ,
> the post (and all the others which screw up indendation) will display
> correctly. On the other hand , messages which respond to a googlegroups
> post through googlegroups , may end up having the mistake forever.

Ah, good point. In fact it's just a surface rendering issue that could
be fixed with the right CSS style. If I edit the text of the element
using Chrome's dev tool, the two spaces are there. So not only is the
text stored correctly, it's pushed out to HTML correctly.

--
Ben.

Re: Sort the data according to the date including the abbreviation of English months.

<87tuam5txz.fsf@bsb.me.uk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5260&group=comp.unix.shell#5260

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben)
Newsgroups: comp.unix.shell
Subject: Re: Sort the data according to the date including the abbreviation of English months.
Date: Thu, 21 Apr 2022 16:37:12 +0100
Organization: A noiseless patient Spider
Lines: 14
Message-ID: <87tuam5txz.fsf@bsb.me.uk>
References: <b57b47bd-f1ad-4af7-95da-d86be093e97fn@googlegroups.com>
<t3o2jv$qe2$1@dont-email.me>
<4029fa37-4165-4217-979d-c3cad7d445a1n@googlegroups.com>
<tdsv5hh5cd9ckjrv5qcjdgk6a8q7o5jmni@dim53.demon.nl>
<c1f564b9-9059-4967-b6e0-7fe2adad1723n@googlegroups.com>
<t3qejc$qgk$1@dont-email.me> <87k0bi7mbm.fsf@bsb.me.uk>
<t3re70$db2$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="0edf30fb0378872d2392a90a7cc48d20";
logging-data="3920"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/RrqUS+ZFp7esn9HFyT4a8zK+Et2JYw/A="
Cancel-Lock: sha1:1UwhDMuSDcbc53Pq1WaEg1rFVV4=
sha1:b/iqwDUG6r5JLBOsIbuvoQcKS98=
X-BSB-Auth: 1.ec1855450c4cd3238752.20220421163712BST.87tuam5txz.fsf@bsb.me.uk
 by: Ben - Thu, 21 Apr 2022 15:37 UTC

Chris Elvidge <chris@mshome.net> writes:

> On 21/04/2022 11:38, Ben wrote:
>> It's only Hongyi Zhao's fault rather indirectly for using Google Groups.
>> The -d\ -f2- is correct when I view Janis's post in my newsreader, but
>> it has already been broken when I view it in GG.
>
> HTML is probably the culprit.
> Multiple spaces (and tabs) are 'condensed' into one space.

Well, it's still GG's fault as that can be fixed using CSS.

--
Ben.

Re: Sort the data according to the date including the abbreviation of English months.

<777d4f85-5fb9-4930-97ac-a567379df48cn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5265&group=comp.unix.shell#5265

  copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:a37:a50:0:b0:69c:7129:12da with SMTP id 77-20020a370a50000000b0069c712912damr1364638qkk.90.1650590190608;
Thu, 21 Apr 2022 18:16:30 -0700 (PDT)
X-Received: by 2002:a05:6214:2507:b0:44c:fa34:b3c8 with SMTP id
gf7-20020a056214250700b0044cfa34b3c8mr1995255qvb.43.1650590190492; Thu, 21
Apr 2022 18:16:30 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Thu, 21 Apr 2022 18:16:30 -0700 (PDT)
In-Reply-To: <625fd8e0$0$481$65785112@news.neostrada.pl>
Injection-Info: google-groups.googlegroups.com; posting-host=203.175.13.156; posting-account=kF0ZaAoAAACPbiK5gldhAyX5qTd3krV2
NNTP-Posting-Host: 203.175.13.156
References: <b57b47bd-f1ad-4af7-95da-d86be093e97fn@googlegroups.com> <625fd8e0$0$481$65785112@news.neostrada.pl>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <777d4f85-5fb9-4930-97ac-a567379df48cn@googlegroups.com>
Subject: Re: Sort the data according to the date including the abbreviation of
English months.
From: hongyi.z...@gmail.com (hongy...@gmail.com)
Injection-Date: Fri, 22 Apr 2022 01:16:30 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 59
 by: hongy...@gmail.com - Fri, 22 Apr 2022 01:16 UTC

On Wednesday, April 20, 2022 at 5:56:54 PM UTC+8, marrgol wrote:
> On 20/04/2022 at 04.50, hongy...@gmail.com wrote:
> > My data includes the following data formats in each row:
> >
> > $ cat 1111
> > Jul 23 2021
> > Apr 30 2019
> > Jan 2 2022
> > Oct 24 2004
> >
> > I want to sort them according to the date, and tried with sort as follows:
> >
> > $ sort -k1 < 1111
> > Apr 30 2019
> > Jan 2 2022
> > Jul 23 2021
> > Oct 24 2004
> >
> > Obviously, this doesn't work as expected. Any hints for dealing with this problem?
> Yeah, the same hint you are always given and never take:
> read the man page and use the information from there.
>
> For dates in the format shown above this should work:
>
> $ sort -b -k3n,3 -k1M,1 -k2n,2 < 1111

sort: option '-b' is ignored

$ cat sort-date
Jul 23 2021
Apr 30 2021
Jan 2 2021
Oct 24 2021

$ sort --debug -b -k3n,3 -k1M,1 -k2n,2 sort-date
sort: using ‘en_CA.UTF-8’ sorting rules
sort: option '-b' is ignored
Jan 2 2021
____
___
_
__________
Apr 30 2021
____
___
__
___________
Jul 23 2021
____
___
__
___________
Oct 24 2021
____
___
__
____________

Re: Sort the data according to the date including the abbreviation of English months.

<t3tr0m$ojl$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5267&group=comp.unix.shell#5267

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Sort the data according to the date including the abbreviation of
English months.
Date: Fri, 22 Apr 2022 11:03:17 +0200
Organization: A noiseless patient Spider
Lines: 62
Message-ID: <t3tr0m$ojl$1@dont-email.me>
References: <b57b47bd-f1ad-4af7-95da-d86be093e97fn@googlegroups.com>
<t3o2jv$qe2$1@dont-email.me>
<4029fa37-4165-4217-979d-c3cad7d445a1n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 22 Apr 2022 09:03:18 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="b79b365ec2183db0c7cf299b6d58e5ac";
logging-data="25205"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+CyYAvforOdDZPmWpszAW9"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:44/ShgBcrO3alNjWRJURYvFj7mQ=
In-Reply-To: <4029fa37-4165-4217-979d-c3cad7d445a1n@googlegroups.com>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Fri, 22 Apr 2022 09:03 UTC

On 20.04.2022 09:06, hongy...@gmail.com wrote:
> On Wednesday, April 20, 2022 at 12:36:21 PM UTC+8, Janis Papanagnou wrote:
>> On 20.04.2022 04:50, hongy...@gmail.com wrote:
>>> My data includes the following data formats in each row:
>>>
>>> $ cat 1111
>>> Jul 23 2021
>>> Apr 30 2019
>>> Jan 2 2022
>>> Oct 24 2004
>>>
>>> I want to sort them according to the date, and tried with sort as follows:
>>>
>>> $ sort -k1 < 1111
>>> Apr 30 2019
>>> Jan 2 2022
>>> Jul 23 2021
>>> Oct 24 2004
>>>
>>> Obviously, this doesn't work as expected. Any hints for dealing with this problem?
>> Generally I'd try to avoid pathological date formats in the first place
>> and create and use ISO-dates or convert the dates to ISO format.
>>
>> Otherwise we probably need more or less clumsy workarounds, e.g. like
>>
>> while read usdate
>> do date -d "${usdate}" "+%Y-%m-%d ${usdate}"
>> done <your_file | sort | cut -d\ -f2-
>
> $ cat usdate
> Jul 23 2021
> Apr 30 2019
> Jan 2 2022
> Oct 24 2004
>
> $ while read usdate
> do date -d "${usdate}" "+%Y-%m-%d ${usdate}"
> done <usdate | sort | cut -d\ -f2-
> cut: the delimiter must be a single character
> Try 'cut --help' for more information.
>

Meanwhile others have pointed out to you a couple issues with your
interpretation and newsgroup interface, so I just add two points...

Is there any incentive for using Google Groups instead of a Real
Newsreader? Especially since you post with an extremely high rate
it would certainly be a gain to switch to something more appropriate.

You seem to "work" heavily based on a copy/paste concept; I suggest
to try to _understand_ the solutions provided. Here you had an issue
with the Google Groups interface, but posters may also decide to post
just hints or untested code (where the idea is valid but typos could
have slipped in). Here the posted solution is just three lines long,
and I'd expect that you can read and understand that code, or can
"analyze" it - if there would really be some tricky part you could
always ask about it -, and have a look into the man pages - ideally
before you post questions - to get the usage information of the used
program patterns (if necessary) as a base to understand the intention.

Janis

Re: Sort the data according to the date including the abbreviation of English months.

<t3u1id$ama$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5270&group=comp.unix.shell#5270

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: chr...@mshome.net (Chris Elvidge)
Newsgroups: comp.unix.shell
Subject: Re: Sort the data according to the date including the abbreviation of
English months.
Date: Fri, 22 Apr 2022 11:55:09 +0100
Organization: A noiseless patient Spider
Lines: 9
Message-ID: <t3u1id$ama$1@dont-email.me>
References: <b57b47bd-f1ad-4af7-95da-d86be093e97fn@googlegroups.com>
<t3o2jv$qe2$1@dont-email.me>
<4029fa37-4165-4217-979d-c3cad7d445a1n@googlegroups.com>
<t3tr0m$ojl$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 22 Apr 2022 10:55:10 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="0a3a3add14bffa8bbae82ab42c7bc206";
logging-data="10954"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19OWNC0Sn15edZBZ0nUcqqTPyhqDNcHDCU="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101
Thunderbird/52.2.1 Lightning/5.4
Cancel-Lock: sha1:3a0vazbtgrKAzmyV212ZiiLOIqU=
In-Reply-To: <t3tr0m$ojl$1@dont-email.me>
Content-Language: en-GB
 by: Chris Elvidge - Fri, 22 Apr 2022 10:55 UTC

On 22/04/2022 10:03, Janis Papanagnou wrote:
> I'd expect that you can read and understand that code, or can
> "analyze" it

As if he would!

--
Chris Elvidge
England

Re: Sort the data according to the date including the abbreviation of English months.

<t3u6kc$j07$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5271&group=comp.unix.shell#5271

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Sort the data according to the date including the abbreviation of
English months.
Date: Fri, 22 Apr 2022 14:21:32 +0200
Organization: A noiseless patient Spider
Lines: 31
Message-ID: <t3u6kc$j07$1@dont-email.me>
References: <b57b47bd-f1ad-4af7-95da-d86be093e97fn@googlegroups.com>
<t3o2jv$qe2$1@dont-email.me>
<4029fa37-4165-4217-979d-c3cad7d445a1n@googlegroups.com>
<t3tr0m$ojl$1@dont-email.me> <t3u1id$ama$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 22 Apr 2022 12:21:32 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="b79b365ec2183db0c7cf299b6d58e5ac";
logging-data="19463"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18xeSkeCO+zA/cbOcnJg/gj"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:BnhE8frj/NaiRQgTcnalaMYAo6E=
In-Reply-To: <t3u1id$ama$1@dont-email.me>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Fri, 22 Apr 2022 12:21 UTC

On 22.04.2022 12:55, Chris Elvidge wrote:
> On 22/04/2022 10:03, Janis Papanagnou wrote:
>> I'd expect that you can read and understand that code, or can
>> "analyze" it
>
> As if he would!

The nice thing about pipelined commands is that they can be (and
often are) incrementally built, and that the same is possible for
functional analysis (or error tracking); with the code

while read usdate
do date -d "${usdate}" "+%Y-%m-%d ${usdate}"
done <your_file | sort | cut -d\ -f2-

if the syntax around 'cut' produced a copy/paste error, he'd just
need to remove that command from the pipeline and make his own
thoughts about how to extract the data he needs from the output
of the preceding commands. Of course he would have to call a man
page to get the details for a solution, and - granted - I have my
doubts about him taking that approach on a regular basis. But at
leasts that's a possible problem solving step he should be aware of.

It was also a good hint in the replies about Google Groups spoiling
the posting format. That didn't occur to me and I certainly wouldn't
adjust posted solutions to fit for being unharmed by Google Groups'
interface behavior. But a [Google Groups] user may keep that in mind
in cases when some posted code "doesn't [seem to] work".

Janis

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor