UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 28th, 2012, 04:48 AM
FalseOnlineID FalseOnlineID is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2012
Posts: 3 FalseOnlineID User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 2 m
Reputation Power: 0
Revision number comparison

Hi,

I am in the process of writing a shell script - basically i currently write the contents of a directory(which contains certain packages) to a text file . something along the lines of this

ls -ltr ${DIR} > /tmp/list.txt

what i need to do is from this list find out which packages are the latest revision as there could be multiple versions of one package.

Any direction would be appreciated

Reply With Quote
  #2  
Old August 28th, 2012, 06:37 AM
SimonJM SimonJM is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Mar 2006
Posts: 2,108 SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 1 Day 4 h 48 m 25 sec
Reputation Power: 1485
The most obvious, and actually not facetious, reply would be ... given the data you see on the screen with the directory listings, how would you do it?
Are the packages all in their own separate directories? Do the directory names include a version number? Is the date stamp for last modification date on the directory 'stable' enough to show correct age of install?
__________________
The moon on the one hand, the dawn on the other:
The moon is my sister, the dawn is my brother.
The moon on my left and the dawn on my right.
My brother, good morning: my sister, good night.
-- Hilaire Belloc

Reply With Quote
  #3  
Old August 28th, 2012, 06:49 AM
FalseOnlineID FalseOnlineID is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2012
Posts: 3 FalseOnlineID User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 2 m
Reputation Power: 0
In this instance we can assume all the packages are in the same directory- And yes they contain revision numbers - i understand that finding the highest (although not necessarily the best option) rev num would supply me with the most recent package.

my issue is how do i find this for each package in the case of there being multiple different packages in this directory
i.e

package1_revnum1
package1_revnum2
package1_revnum3
package2_revnum1
package2_revnum2


where i would want to take both package1_revnum3 and package2_revnum3

thanks for the reply

Reply With Quote
  #4  
Old August 30th, 2012, 07:13 AM
SimonJM SimonJM is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Mar 2006
Posts: 2,108 SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level)SimonJM User rank is General 8th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 1 Week 1 Day 4 h 48 m 25 sec
Reputation Power: 1485
Could approach is a few ways, but my best guess would be:
Chuck it through awk (using field delimiter of _) and using an array keyed on package name (in field 1) compare version numbers (field 2), storing only if higher.

Reply With Quote
  #5  
Old August 30th, 2012, 07:53 AM
FalseOnlineID FalseOnlineID is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2012
Posts: 3 FalseOnlineID User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 2 m
Reputation Power: 0
Quote:
Originally Posted by SimonJM
Could approach is a few ways, but my best guess would be:
Chuck it through awk (using field delimiter of _) and using an array keyed on package name (in field 1) compare version numbers (field 2), storing only if higher.


Simon,

That was my initial idea although i found a simpler solution, i was able to write the contents of the directory to a .txt file ( ls -tr directory > file.txt ) and then in a for loop `grep "${package}_" file.txt | tail -n1`

This solution would take the last package that was modified.

Thank you for your help

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > Revision number comparison

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap