Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


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

Rep: Reputation: 15
Parse RPM version string in Bash


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.


#Perform sed awk to Parse out
#version values as followes
# VER_REL="05"

Any suggestions or help will be greatly appreciate.

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

Rep: Reputation: 378Reputation: 378Reputation: 378Reputation: 378
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...


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

All times are GMT -5. The time now is 08:17 PM.

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