Slackware This Forum is for the discussion of Slackware Linux.
|
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
|
10-14-2013, 03:05 AM
|
#16
|
Senior Member
Registered: Jan 2011
Location: Oslo, Norway
Distribution: Slackware
Posts: 2,559
|
Actually removing the sed part keeps it simpler and allows you to see the exact match(es), e.g.:
Code:
$ cat scriptname
#!/bin/sh
bzcat ~/MANIFEST.bz2 | grep -Fe "|| Package:" -e "$1" | grep -B1 -F "$1"
$ scriptname libmpfr
|| Package: ./a/aaa_elflibs-14.0-i486-4.txz
-rwxr-xr-x root/root 299212 2012-06-29 11:59 usr/lib/libmpfr.so.1.2.2
--
|| Package: ./l/mpfr-3.1.0-i486-1.txz
-rwxr-xr-x root/root 941 2012-03-23 21:57 usr/lib/libmpfr.la
-rwxr-xr-x root/root 369804 2012-03-23 21:57 usr/lib/libmpfr.so.4.1.0
-rw-r--r-- root/root 679242 2012-03-23 21:57 usr/lib/libmpfr.a
|
|
1 members found this post helpful.
|
10-14-2013, 09:03 AM
|
#17
|
Member
Registered: May 2004
Distribution: BSD
Posts: 269
Rep: 
|
Thanks a lot, ruario, I'm now using the following:
Code:
bzcat "$m" | grep -Fe "|| Package:" -e "$arg" | \
grep -B1 -F "$arg" | sed -n 's/|| Package: //p' | \
grep -v \/source\/ | sed 's/^\.\///'
And get an output like this:
Code:
[a] aaa_elflibs-14.1-i486-2
[l] mpfr-3.1.2-i486-1
--or--
[a][*] aaa_elflibs-14.1-i486-2
[l] [ ] mpfr-3.1.2-i486-1
Last edited by lems; 10-14-2013 at 09:24 AM.
Reason: Different output
|
|
|
10-14-2013, 01:44 PM
|
#18
|
Senior Member
Registered: Jan 2011
Location: Oslo, Norway
Distribution: Slackware
Posts: 2,559
|
@lems: Just use one sed call, rather than two, e.g.:
Code:
sed -n 's,|| Package: .*/\(.*\),\1,p'
EDIT: Also, you don't need to escape the slashes in your grep command. Something like this should work:
Code:
bzcat "$m" | grep -Fe "|| Package:" -e "$arg" | \
grep -FB1 "$arg" | sed -n 's,|| Package: .*/\(.*\),\1,p' | \
grep -v /source/
Last edited by ruario; 10-14-2013 at 04:25 PM.
|
|
1 members found this post helpful.
|
10-15-2013, 07:30 AM
|
#19
|
Member
Registered: May 2004
Distribution: BSD
Posts: 269
Rep: 
|
Quote:
Originally Posted by ruario
@lems: Just use one sed call, rather than two, e.g.:
Code:
sed -n 's,|| Package: .*/\(.*\),\1,p'
EDIT: Also, you don't need to escape the slashes in your grep command. Something like this should work:
Code:
bzcat "$m" | grep -Fe "|| Package:" -e "$arg" | \
grep -FB1 "$arg" | sed -n 's,|| Package: .*/\(.*\),\1,p' | \
grep -v /source/
|
Thanks for the hints, ruario. Though with the new sed command, it no longer preserves the series directory, which I found quite neat.
(On a sidenote, I've now implemented an « OpenBSD installer style » select/deselect mechanism, so one can select/deselect packages by typing a part of their name. This is not as convenient as a dialog interface, but a nice compromise.)
|
|
|
All times are GMT -5. The time now is 04:05 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|