LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-28-2005, 04:48 PM   #1
jimwelc
Member
 
Registered: Nov 2004
Location: Boston
Posts: 30

Rep: Reputation: 15
Parse RPM version string in Bash


Hello,

I am very new to bash scripting and I am trying to break down a rpm version string into four separate strings.

Basically I have a Version string I retrieve from a file( for example sake lets say it is "1.0.1-05" and I would like to break it down and store it into four separte strings/or numbers. I think I might be able to use the awk/sed command to do this but I can not figure out the usage.

VER_STR="1.0.1-05"

#Perform sed awk to Parse out
#version values as followes
# VER_MAJOR="1"
# VER_MINOR="0"
# VER_BUILD="1"
# VER_REL="05"



Any suggestions or help will be greatly appreciate.


Best Regards,
-Jim
 
Old 02-28-2005, 06:22 PM   #2
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,275

Rep: Reputation: 370Reputation: 370Reputation: 370Reputation: 370
This is harder than in initially appears (I know, I've tried it) because there is not standard way of doing version numbers. You might want to tackle this with Perl and handle a few common cases (you can to it with sed or awk, but when things get this heavy I tend to go for Perl). You'd want to use the split routine to split the string into its component parts. Maybe ifyou google you'll find a pre-rolled solution...
 
  


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
Parse String in a Bash script jimwelc Linux - Newbie 8 11-09-2012 08:47 AM
c++ parse date string?? blizunt7 Programming 25 05-18-2006 04:12 PM
Parse --static string no delimiters DaFrEQ Programming 2 04-08-2005 03:06 PM
Parse a perl string djgerbavore Programming 3 10-31-2004 08:23 AM
C++ and C# Parse a string into a numerical type exodist Programming 8 02-23-2004 07:15 AM


All times are GMT -5. The time now is 02:31 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