LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Sed/awk magic to change rpm naming convention (https://www.linuxquestions.org/questions/linux-newbie-8/sed-awk-magic-to-change-rpm-naming-convention-933585/)

dann_radkov 03-09-2012 06:13 AM

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

Cedrik 03-09-2012 06:25 AM

Would this work ?

Code:

perl -pe 's/(.*?)-\d.*/\1/' list.txt

dann_radkov 03-09-2012 06:54 AM

All I can say is WOW! I will definitely look into perl!Thanks for this.

grail 03-09-2012 10:21 AM

Or sed:
Code:

sed 's/-[0-9].*//' file


All times are GMT -5. The time now is 03:02 AM.