LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-25-2014, 09:00 AM   #1
Glenn D.
Member
 
Registered: May 2009
Location: ACT - Australia
Distribution: Opensuse x86_64 (Latest)
Posts: 132

Rep: Reputation: 26
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
 
Old 06-25-2014, 09:31 AM   #2
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,267

Rep: Reputation: 914Reputation: 914Reputation: 914Reputation: 914Reputation: 914Reputation: 914Reputation: 914Reputation: 914
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

Last edited by schneidz; 06-25-2014 at 09:37 AM.
 
Old 06-25-2014, 10:42 AM   #3
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 13,501

Rep: Reputation: 4314Reputation: 4314Reputation: 4314Reputation: 4314Reputation: 4314Reputation: 4314Reputation: 4314Reputation: 4314Reputation: 4314Reputation: 4314Reputation: 4314
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

Last edited by pan64; 06-25-2014 at 10:43 AM.
 
Old 06-25-2014, 08:53 PM   #4
Glenn D.
Member
 
Registered: May 2009
Location: ACT - Australia
Distribution: Opensuse x86_64 (Latest)
Posts: 132

Original Poster
Rep: Reputation: 26
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
 
Old 06-26-2014, 01:08 AM   #5
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 13,501

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How to list only files, sorted by date? Calab Linux - Newbie 2 03-25-2014 06:56 PM
How to display all rpm installed list sorted by date yzhang738@hotmail.com Linux - Newbie 3 10-05-2010 12:44 AM
System suddenly changing disk order from BIOS order hscast Fedora 2 02-16-2010 10:09 PM
what is the correct syntax order for tar with --after-date DATE, --newer DAT farhan Linux - General 1 03-16-2007 09:43 AM
Filenames are sorted in wrong order Simoncifer Linux - Newbie 4 01-07-2005 01:52 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:32 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration