LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   How can this list be sorted in date order of YYYY-MMM-DD order. (https://www.linuxquestions.org/questions/linux-software-2/how-can-this-list-be-sorted-in-date-order-of-yyyy-mmm-dd-order-4175509125/)

Glenn D. 06-25-2014 08:00 AM

How can this list be sorted in date order of YYYY-MMM-DD order.
 
Hello,
How can this list[1] be sorted in date order of YYYY-MMM-DD order.

It is gotten and processed,see [2]
- Number of entries to process in list: 12964
- Using Opensuse.
Thanks Glenn

[1] List contains 12964 entries [this is a small part of it]
.
4ti2-1.6.2-1.1.x86_64.rpm 06-May-2014
4ti2-devel-1.6.2-1.1.x86_64.rpm 06-May-2014
CharLS-devel-1.0-9.6.x86_64.rpm 09-Apr-2014
ColPack-devel-1.0.9-5.7.x86_64.rpm 09-Apr-2014
ColPack-devel-32bit-1.0.9-5.7.x86_64.rpm 09-Apr-2014
ConsoleKit-0.4.6-3.1.x86_64.rpm 27-May-2014
ConsoleKit-32bit-0.4.6-3.1.x86_64.rpm 27-May-2014
ConsoleKit-devel-0.4.6-3.1.x86_64.rpm 27-May-2014
ConsoleKit-doc-0.4.6-3.1.x86_64.rpm 27-May-2014
..
rubygem-shoes-testsuite-3.0.1-1.1.x86_64.rpm 18-Mar-2014
rubygem-simple_oauth-0.2.0-5.5.x86_64.rpm 04-Mar-2014
rubygem-simple_oauth-doc-0.2.0-5.5.x86_64.rpm 04-Mar-2014
rubygem-simple_oauth-testsuite-0.2.0-5.5.x86_64.rpm 04-Mar-2014
rubygem-simplecov-0.8.2-1.3.x86_64.rpm 09-Apr-2014
rubygem-simplecov-doc-0.8.2-1.3.x86_64.rpm 09-Apr-2014
rubygem-simplecov-html-0.8.0-1.4.x86_64.rpm 04-Mar-2014
rubygem-simplecov-html-doc-0.8.0-1.4.x86_64.rpm 04-Mar-2014
rubygem-simplecov-html-testsuite-0.8.0-1.4.x86_64.rpm 04-Mar-2014
..
rzsz-0.12.20-998.1.x86_64.rpm 13-May-2014
s2tc-20130202-2.1.x86_64.rpm 05-May-2014

[2] - gotten and processed with commands:

# rm index.html
# wget -c http://mirrors1.kernel.org/opensuse/...s/suse/x86_64/
--2014-06-25 21:33:00-- http://mirrors1.kernel.org/opensuse/...s/suse/x86_64/
Resolving mirrors1.kernel.org (mirrors1.kernel.org)... 149.20.20.135, 149.20.4.71
Connecting to mirrors1.kernel.org (mirrors1.kernel.org)|149.20.20.135|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘index.html’

[ <=> ] 2,202,140 863KB/s in 2.5s

2014-06-25 21:33:03 (863 KB/s) - ‘index.html’ saved [2202140]


# grep -i "\.rpm" index.html | cut -d">" -f2-3 | sed 's/^[ \t]*//' | sed 's/<\/a>//' | cut -c 1-103 |head
4ti2-1.6.2-1.1.x86_64.rpm 06-May-2014
4ti2-devel-1.6.2-1.1.x86_64.rpm 06-May-2014
CharLS-devel-1.0-9.6.x86_64.rpm 09-Apr-2014
ColPack-devel-1.0.9-5.7.x86_64.rpm 09-Apr-2014
ColPack-devel-32bit-1.0.9-5.7.x86_64.rpm 09-Apr-2014
ConsoleKit-0.4.6-3.1.x86_64.rpm 27-May-2014
ConsoleKit-32bit-0.4.6-3.1.x86_64.rpm 27-May-2014
ConsoleKit-devel-0.4.6-3.1.x86_64.rpm 27-May-2014
ConsoleKit-doc-0.4.6-3.1.x86_64.rpm 27-May-2014


# number of entries to process in list

# grep -i "\.rpm" index.html | cut -d">" -f2-3 | sed 's/^[ \t]*//' | sed 's/<\/a>//' | cut -c 1-103 |wc -l
12964


# raw list

# grep -i "\.rpm" index.html | head
<a href="4ti2-1.6.2-1.1.x86_64.rpm">4ti2-1.6.2-1.1.x86_64.rpm</a> 06-May-2014 15:46 392K
<a href="4ti2-devel-1.6.2-1.1.x86_64.rpm">4ti2-devel-1.6.2-1.1.x86_64.rpm</a> 06-May-2014 15:46 70K
<a href="CharLS-devel-1.0-9.6.x86_64.rpm">CharLS-devel-1.0-9.6.x86_64.rpm</a> 09-Apr-2014 20:33 21K
<a href="ColPack-devel-1.0.9-5.7.x86_64.rpm">ColPack-devel-1.0.9-5.7.x86_64.rpm</a> 09-Apr-2014 16:50 33K
<a href="ColPack-devel-32bit-1.0.9-5.7.x86_64.rpm">ColPack-devel-32bit-1.0.9-5.7.x86_64.rpm</a> 09-Apr-2014 18:29 3.3K
<a href="ConsoleKit-0.4.6-3.1.x86_64.rpm">ConsoleKit-0.4.6-3.1.x86_64.rpm</a> 27-May-2014 06:00 98K
<a href="ConsoleKit-32bit-0.4.6-3.1.x86_64.rpm">ConsoleKit-32bit-0.4.6-3.1.x86_64.rpm</a> 27-May-2014 05:51 18K
<a href="ConsoleKit-devel-0.4.6-3.1.x86_64.rpm">ConsoleKit-devel-0.4.6-3.1.x86_64.rpm</a> 27-May-2014 06:00 13K
<a href="ConsoleKit-doc-0.4.6-3.1.x86_64.rpm">ConsoleKit-doc-0.4.6-3.1.x86_64.rpm</a> 27-May-2014 05:59 21K
<a href="ConsoleKit-x11-0.4.6-3.1.x86_64.rpm">ConsoleKit-x11-0.4.6-3.1.x86_64.rpm</a> 27-May-2014 06:00 20K

schneidz 06-25-2014 08:31 AM

convert the 2nd feild using the date command.

e.g.: read each line in a while loop. cut the 2nd feild into date; print the converted 2nd feild then the 1st feild; then sort.
Code:

[schneidz@hyper ~]$ date --date "may 27 2014" +%Y-%j
2014-147


pan64 06-25-2014 09:42 AM

probably grep -c rpm index.html is enough to count occurrences.
I would replace name of months to numbers (and - to space) and run a numeric sort on those three fields (year, month and day).
Edit: sort can handle month names, therefore no sed required

Glenn D. 06-25-2014 07:53 PM

Hello,
A following question:
- What is the command to replace name of months to numbers (and - to space) and run a numeric sort on those three fields (year, month and day). ?

Thanks Glenn

pan64 06-26-2014 12:08 AM

sed is used to manipulate text (replace strings) and sort is the name of the command to sort. See man pages...


All times are GMT -5. The time now is 02:39 PM.