LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices



Reply
 
Search this Thread
Old 07-14-2012, 04:36 AM   #1
Glenn D.
Member
 
Registered: May 2009
Location: ACT - Australia
Distribution: Opensuse x86_64 (Latest)
Posts: 87

Rep: Reputation: 16
How can I extract the .rpm filename from long list of entries using bash shell script


Hello
How can I extract the .rpm filename from a long list of entries using bash shell script.
The .rpm filename is at the end of each line, one .rpm filename per line.
An small sample of entries see[1]

Thanks Glenn

[1]
25178 Jul 05 12 ./opensuse/repositories/home:/thomas-worm-datev:/branches:/openSUSE:/12.1:/Update/standard/i586/php5-enchant-5.4.2-2.10.i586.rpm
34376 Jul 05 12 ./opensuse/repositories/home:/thomas-worm-datev:/branches:/openSUSE:/12.1:/Update/standard/i586/php5-enchant-debuginfo-5.4.2-2.10.i586.rpm
37953 Jul 05 12 ./opensuse/repositories/home:/thomas-worm-datev:/branches:/openSUSE:/12.1:/Update/standard/i586/php5-exif-5.4.2-2.10.i586.rpm
48762 Jul 05 12 ./opensuse/repositories/home:/thomas-worm-datev:/branches:/openSUSE:/12.1:/Update/standard/i586/php5-exif-debuginfo-5.4.2-2.10.i586.rpm
1163812 Jul 05 12 ./opensuse/repositories/home:/thomas-worm-datev:/branches:/openSUSE:/12.1:/Update/standard/i586/php5-fastcgi-5.4.2-2.10.i586.rpm
2253098 Jul 05 12 ./opensuse/repositories/home:/thomas-worm-datev:/branches:/openSUSE:/12.1:/Update/standard/i586/php5-fastcgi-debuginfo-5.4.2-2.10.i586.rpm
177128 Jul 05 12 ./opensuse/repositories/home:/thomas-worm-datev:/branches:/openSUSE:/12.1:/Update/standard/i586/php5-fileinfo-5.4.2-2.10.i586.rpm
113810 Jul 05 12 ./opensuse/repositories/home:/thomas-worm-datev:/branches:/openSUSE:/12.1:/Update/standard/i586/php5-fileinfo-debuginfo-5.4.2-2.10.i586.rpm
1190720 Jul 05 12 ./opensuse/repositories/home:/thomas-worm-datev:/branches:/openSUSE:/12.1:/Update/standard/i586/php5-fpm-5.4.2-2.10.i586.rpm
12416684 Feb 14 12 ./opensuse/update/12.1/x86_64/xulrunner-devel-10.0.1-2.19.1.x86_64.rpm
12377361 Feb 10 12 ./opensuse/update/12.1/x86_64/xulrunner-devel-10.0-2.17.3.x86_64.rpm
12387183 Feb 23 12 ./opensuse/update/12.1/x86_64/xulrunner-devel-10.0.2-2.21.1.x86_64.rpm
12380383 Mär 27 12 ./opensuse/update/12.1/x86_64/xulrunner-devel-11.0-2.23.1.x86_64.rpm
12517313 Apr 27 12 ./opensuse/update/12.1/x86_64/xulrunner-devel-12.0-2.26.1.x86_64.rpm
12618902 Jun 19 12 ./opensuse/update/12.1/x86_64/xulrunner-devel-13.0-2.29.2.x86_64.rpm
14987262 Nov 17 11 ./opensuse/update/12.1/x86_64/xulrunner-devel-8.0-2.3.1.x86_64.rpm
14969617 Jan 23 12 ./opensuse/update/12.1/x86_64/xulrunner-devel-9.0.1-2.15.1.x86_64.rpm
14882742 Dez 22 11 ./opensuse/update/12.1/x86_64/xulrunner-devel-9.0-2.6.1.x86_64.rpm
86423 Nov 24 11 ./opensuse/update/12.1/x86_64/yast2-snapper-2.21.16.1-2.3.1.x86_64.rpm
49923 Feb 15 12 ./opensuse/update/12.1/x86_64/zlib-1.2.5_git201105272030-20.3.1.x86_64.rpm
51021 Feb 15 12 ./opensuse/update/12.1/x86_64/zlib-32bit-1.2.5_git201105272030-20.3.1.x86_64.rpm
55781 Feb 15 12 ./opensuse/update/12.1/x86_64/zlib-devel-1.2.5_git201105272030-20.3.1.x86_64.rpm
6915 Feb 15 12 ./opensuse/update/12.1/x86_64/zlib-devel-32bit-1.2.5_git201105272030-20.3.1.x86_64.rpm
107492 Feb 15 12 ./opensuse/update/12.1/x86_64/zlib-devel-static-1.2.5_git201105272030-20.3.1.x86_64.rpm
2613937 Jun 25 12 ./opensuse/update/12.1/x86_64/zsh-4.3.12-6.4.1.x86_64.rpm
405800 Jun 25 12 ./opensuse/update/12.1/x86_64/zsh-htmldoc-4.3.12-6.4.1.x86_64.rpm
45784 Jun 14 12 ./opensuse/repositories/home:/AndreasSchwab:/12.1/12.1/x86_64/orc-0.4.16-2.1.9.x86_64.rpm
33395 Jun 14 12 ./opensuse/repositories/home:/AndreasSchwab:/12.1/12.1/x86_64/orc-debuginfo-0.4.16-2.1.9.x86_64.rpm
8615 Jun 14 12 ./opensuse/repositories/home:/AndreasSchwab:/12.1/12.1/x86_64/orc-debugsource-0.4.16-2.1.9.x86_64.rpm
49739 Jun 14 12 ./opensuse/repositories/home:/AndreasSchwab:/12.1/12.1/x86_64/orc-doc-0.4.16-2.1.9.x86_64.rpm
404717 Jun 16 12 ./opensuse/repositories/home:/AndreasSchwab:/12.1/12.1/x86_64/oxygen-gtk-1.1.4-2.4.4.x86_64.rpm
361134 Jun 15 12 ./opensuse/repositories/home:/AndreasSchwab:/12.1/12.1/x86_64/oxygen-gtk-32bit-1.1.4-2.4.4.x86_64.rpm
4739806 Jun 16 12 ./opensuse/repositories/home:/AndreasSchwab:/12.1/12.1/x86_64/oxygen-gtk-debuginfo-1.1.4-2.4.4.x86_64.rpm
4384492 Jun 15 12 ./opensuse/repositories/home:/AndreasSchwab:/12.1/12.1/x86_64/oxygen-gtk-debuginfo-32bit-1.1.4-2.4.4.x86_64.rpm
5548 Jun 15 12 ./opensuse/repositories/home:/AndreasSchwab:/12.1/12.1/x86_64/oxygen-gtk-debugsource-1.1.4-2.4.4.x86_64.rpm
54102 Jul 03 12 ./opensuse/repositories/home:/AndreasSchwab:/12.1/12.1/x86_64/p11-kit-module-gnome-keyring-3.2.1-2.6.2.x86_64.rpm
52369 Jul 02 12 ./opensuse/repositories/home:/AndreasSchwab:/12.1/12.1/x86_64/p11-kit-module-gnome-keyring-32bit-3.2.1-2.6.2.x86_64.rpm
75112 Jul 03 12 ./opensuse/repositories/home:/AndreasSchwab:/12.1/12.1/x86_64/p11-kit-module-gnome-keyring-debuginfo-3.2.1-2.6.2.x86_64.rpm
69578 Jul 02 12 ./opensuse/repositories/home:/AndreasSchwab:/12.1/12.1/x86_64/p11-kit-module-gnome-keyring-debuginfo-32bit-3.2.1-2.6.2.x86_64.rpm
 
Old 07-14-2012, 05:18 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,811
Blog Entries: 54

Rep: Reputation: 2986Reputation: 2986Reputation: 2986Reputation: 2986Reputation: 2986Reputation: 2986Reputation: 2986Reputation: 2986Reputation: 2986Reputation: 2986Reputation: 2986
Using
Code:
awk -F'/' '/\.rpm$/ {print $NF}'
to pipe through or adding a file name as last element returns all lines ending in ".rpm" and displays the last item of slash-separated strings, meaning here all package names.
 
Old 07-14-2012, 06:42 AM   #3
Glenn D.
Member
 
Registered: May 2009
Location: ACT - Australia
Distribution: Opensuse x86_64 (Latest)
Posts: 87

Original Poster
Rep: Reputation: 16
Thanks for the details this worked --Glenn
# cat t.txt
198341 Feb 26 12 ./linux/misc/mondorescue/opensuse/12.1/i386/mindi-2.1.1-1.opensuse12.1.i586.rpm
323850 Feb 26 12 ./linux/misc/mondorescue/opensuse/12.1/i386/mindi-2.1.1-1.opensuse12.1.src.rpm
203899 Jun 04 12 ./linux/misc/mondorescue/opensuse/12.1/i386/mindi-2.1.2-1.opensuse12.1.i586.rpm
332979 Jun 04 12 ./linux/misc/mondorescue/opensuse/12.1/i386/mindi-2.1.2-1.opensuse12.1.src.rpm
205445 Jul 08 12 ./linux/misc/mondorescue/opensuse/12.1/i386/mindi-2.1.3-1.opensuse12.1.i586.rpm
334907 Jul 08 12 ./linux/misc/mondorescue/opensuse/12.1/i386/mindi-2.1.3-1.opensuse12.1.src.rpm
243145 Feb 26 12 ./linux/misc/mondorescue/opensuse/12.1/i386/mindi-busybox-1.18.5-2.opensuse12.1.i586.rpm
3132736 Feb 26 12 ./linux/misc/mondorescue/opensuse/12.1/i386/mindi-busybox-1.18.5-2.opensuse12.1.src.rpm
1132975 Feb 26 12 ./linux/misc/mondorescue/opensuse/12.1/i386/mondo-3.0.1-1.opensuse12.1.i586.rpm
2532903 Feb 26 12 ./linux/misc/mondorescue/opensuse/12.1/i386/mondo-3.0.1-1.opensuse12.1.src.rpm
# cat t.txt | awk -F'/' '/\.rpm/ {print $NF}'
mindi-2.1.1-1.opensuse12.1.i586.rpm
mindi-2.1.1-1.opensuse12.1.src.rpm
mindi-2.1.2-1.opensuse12.1.i586.rpm
mindi-2.1.2-1.opensuse12.1.src.rpm
mindi-2.1.3-1.opensuse12.1.i586.rpm
mindi-2.1.3-1.opensuse12.1.src.rpm
mindi-busybox-1.18.5-2.opensuse12.1.i586.rpm
mindi-busybox-1.18.5-2.opensuse12.1.src.rpm
mondo-3.0.1-1.opensuse12.1.i586.rpm
mondo-3.0.1-1.opensuse12.1.src.rpm
 
  


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
Need a shell script help - grepping list of entries from another file? Jykke Linux - General 3 07-12-2011 08:40 AM
How do I extract data from nmblookup in bash shell script? utahnix Linux - General 23 10-12-2009 05:28 AM
how to remove long-windows-filename files based on exlusion list adamrosspayne Linux - Newbie 3 06-23-2006 03:25 AM
linux shell - extract filename from and song info from text database d003 Programming 1 07-23-2003 05:06 AM
accepting root passwd from UI and passing it to a shell script to extract a rpm rameshvl Linux - Software 4 03-18-2003 01:11 AM


All times are GMT -5. The time now is 04:49 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration