LinuxQuestions.org
Visit Jeremy's Blog.
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 03-09-2012, 06:13 AM   #1
dann_radkov
Member
 
Registered: Sep 2011
Posts: 52

Rep: Reputation: Disabled
Sed/awk magic to change rpm naming convention


Hey Guys,
I need to come up with an easy way to change the naming convention form this list.
I want to specify a list where only RPM names are displayed.
I don`t want the traditional pattern ,which is name-version-release.architecture.rpm
Bad part is that not all those rpm`s follow the same naming convention.Meaning sometimes they are logically named:
somerpm-someversion-somerelease.architecture.rpm
And in this case I can get what I want.
Sometimes some genius created this:
some-rpm-some-version-somerelease.architecture



389-ds-base-devel-1.2.8.2-1.el6_1.3.i686.rpm
389-ds-base-libs-1.2.8.2-1.el6_1.3.i686.rpm
abrt-devel-1.1.16-3.el6.i686.rpm
abrt-libs-1.1.16-3.el6.i686.rpm
akonadi-1.2.1-2.el6.i686.rpm
alsa-lib-1.0.21-3.el6.i686.rpm
alsa-lib-devel-1.0.21-3.el6.i686.rpm
alsa-plugins-pulseaudio-1.0.21-3.el6.i686.rpm
amanda-2.6.1p2-7.el6.i686.rpm
anthy-9100h-10.1.el6.i686.rpm
apr-1.3.9-3.el6_1.2.i686.rpm
apr-devel-1.3.9-3.el6_1.2.i686.rpm
apr-util-1.3.9-3.el6_0.1.i686.rpm
apr-util-devel-1.3.9-3.el6_0.1.i686.rpm
arts-1.5.10-10.el6.i686.rpm
arts-devel-1.5.10-10.el6.i686.rpm
aspell-0.60.6-12.el6.i686.rpm
atk-1.28.0-2.el6.i686.rpm
atk-devel-1.28.0-2.el6.i686.rpm
atlas-3.8.3-12.4.el6.i686.rpm
at-spi-1.28.1-2.el6.i686.rpm
audiofile-0.2.6-11.1.el6.i686.rpm

Please let me know if this can be done.
libgpg-error-1.7-3.el6.i686.rpm
libgpg-error-devel-1.7-3.el6.i686.rpm
libgphoto2-2.4.7-4.el6.i686.rpm
libgphoto2-devel-2.4.7-4.el6.i686.rpm
libgpod-0.7.2-6.el6.i686.rpm
libgsf-1.14.15-5.el6.i686.rpm
libgsf-devel-1.14.15-5.el6.i686.rpm
libgssglue-0.1-11.el6.i686.rpm
libgssglue-devel-0.1-11.el6.i686.rpm
libgudev1-147-2.35.el6.i686.rpm
libgudev1-devel-147-2.35.el6.i686.rpm
libgweather-2.28.0-4.el6.i686.rpm
libgweather-devel-2.28.0-4.el6.i686.rpm
libgxim-0.3.3-3.1.el6.i686.rpm
libhangul-0.0.10-1.el6.i686.rpm
libhbaapi-2.2-10.el6.i686.rpm
libhbalinux-1.0.10-3.el6.i686.rpm
libhugetlbfs-2.8-2.el6.i686.rpm
libhugetlbfs-devel-2.8-2.el6.i686.rpm
libibcm-1.0.5-2.el6.i686.rpm
libibcommon-1.2.0-3.el6.i686.rpm

---------- Post added 03-09-12 at 02:14 PM ----------

So basically @ the end I want to have
apr-devel
libibcommon
libgsf-devel etc
 
Old 03-09-2012, 06:25 AM   #2
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 242Reputation: 242Reputation: 242
Would this work ?

Code:
perl -pe 's/(.*?)-\d.*/\1/' list.txt
 
1 members found this post helpful.
Old 03-09-2012, 06:54 AM   #3
dann_radkov
Member
 
Registered: Sep 2011
Posts: 52

Original Poster
Rep: Reputation: Disabled
All I can say is WOW! I will definitely look into perl!Thanks for this.
 
Old 03-09-2012, 10:21 AM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,529

Rep: Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896Reputation: 2896
Or sed:
Code:
sed 's/-[0-9].*//' file
 
  


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
Basic question regarding rpm naming convention. pinga123 Linux - Newbie 2 03-17-2011 12:52 AM
C - Function naming convention golmschenk Programming 10 02-16-2010 08:14 PM
file naming convention soldan Linux - Newbie 13 05-15-2006 11:11 AM
usb naming convention hoover93 Linux - Hardware 5 10-19-2005 10:18 PM
mail server the naming naming convention problem kashan Linux - Newbie 0 07-16-2004 02:08 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:14 PM.

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