You are not logged in.

#1 2008-09-04 15:24:59

indianahorst
Member
Registered: 2008-08-23
Posts: 128

How to search ONLY in package names, without descriptions?

Hello!

I would like to know how I can search with pacman only in the package names, without searching descriptions?

For example, searching for the rar package (pacman -Ss rar) gives me tons of results with hundreds of packages, where "library" occurs in the description.

I have already read the pacman manual page, but I couldn't find anything suitable.

Greets, Horst

Offline

#2 2008-09-04 15:37:01

RobertoVanto
Member
From: Chiampo(VI) - Italy
Registered: 2008-09-04
Posts: 32
Website

Re: How to search ONLY in package names, without descriptions?

find /var/abs -type d -name *rar*


Love, and do what thou wilt  - St. Augustine of Hippo

Offline

#3 2008-09-04 17:25:47

Daenyth
Forum Fellow
From: Boston, MA
Registered: 2008-02-24
Posts: 1,244

Re: How to search ONLY in package names, without descriptions?

You could pacman -Sl core extra community | grep rar.

Offline

#4 2008-09-04 19:06:04

haxit
Member
From: /home/haxit
Registered: 2008-03-04
Posts: 1,247
Website

Re: How to search ONLY in package names, without descriptions?

How about:

pacman -Slq | grep <package>


Archi686 User | Old Screenshots | Old .Configs
Vi veri universum vivus vici.

Offline

#5 2008-09-04 19:28:45

Daenyth
Forum Fellow
From: Boston, MA
Registered: 2008-02-24
Posts: 1,244

Re: How to search ONLY in package names, without descriptions?

Woops, yeah, I meant -Slq.

Offline

#6 2008-09-04 19:35:45

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Re: How to search ONLY in package names, without descriptions?

perl -e '$search = "rar";$output=`pacman -Ss $search`;while($output=~/^(\S.*?\Q$search\E.*?\n(?:\s.*\n)*)/mgi){print $1}'

This does the normal "pacman -Ss whatever" search, but then it checks that the search term is in the package name. Just replace "rar" in "$search = "rar" with whatever you want to search for.

I tried to make it work with grep using -P, but I still don't know how to make it case-insensitive then ("-i" doesn't seem to work with perl regexes). Here it is anyway though:

pacman -Ss rar | grep -P "^\S.*?rar(?:.*|\n)*?(?=\n\S)"

Aside from being case-sensitive, you also have to replace both instances of "rar" with your search term.


Here's a script version that you can run from the command line:

#!/usr/bin/perl
use strict;
use warnings;


my $search = "@ARGV";
my $output = '';

open(my $pipe,'-|',"pacman -Ss $search") or die "Unable to create pipe to pacman: $!\n";
while (defined(my $line=<$pipe>)){$output.=$line;}
close $pipe;
while($output=~/^(\S.*?\Q$search\E.*?\n(?:\s.*\n)*)/mgi){print $1};

Save it as "search_pkgnames", make it executable, then invoke it with your search term: search_pkgnames rar

Hope this helps.


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#7 2008-09-04 20:05:41

finferflu
Forum Fellow
From: Manchester, UK
Registered: 2007-06-21
Posts: 1,899
Website

Re: How to search ONLY in package names, without descriptions?

You can even alias the above script to work with pacman, i.e. alias "pacman -Sp" /path/to/search_pkgnames.


Have you Syued today?
Free music for free people! | Earthlings

"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." -- A. de Saint-Exupery

Offline

#8 2008-09-04 20:24:40

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Re: How to search ONLY in package names, without descriptions?

finferflu wrote:

You can even alias the above script to work with pacman, i.e. alias "pacman -Sp" /path/to/search_pkgnames.

I would suggest something other than "-Sp" as that's for printing the URIs... perhaps "pacman -Ss --by-name" instead.

Interesting idea btw... I hadn't even considered making aliases like that.
*walks off rubbing hands together at newfound power*

Last edited by Xyne (2008-09-04 20:36:57)


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#9 2008-09-04 20:58:32

finferflu
Forum Fellow
From: Manchester, UK
Registered: 2007-06-21
Posts: 1,899
Website

Re: How to search ONLY in package names, without descriptions?

Oops, you're right, I had forgotten about the -p flag. How about pacman -Sss? big_smile


Have you Syued today?
Free music for free people! | Earthlings

"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." -- A. de Saint-Exupery

Offline

Board footer

Powered by FluxBB