You are not logged in.

#1 2018-05-11 14:47:48

j1simon
Member
From: Denmark
Registered: 2016-01-28
Posts: 189

List all local packages whose name begins with ...

Hi,
I want to list all local packages whose name begins with 'gnome'. I've tried "pacman -Qs '^gnome'" but it doesn't work. Only it works this: "pacman -Qs 'gnome' | grep '^local/gnome'".
If pacman accepts regular expressions in the search, why doesn't it work without using grep?

Offline

#2 2018-05-11 15:01:51

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,530
Website

Re: List all local packages whose name begins with ...


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2018-05-11 15:03:28

j1simon
Member
From: Denmark
Registered: 2016-01-28
Posts: 189

Re: List all local packages whose name begins with ...

Thanks but I don't search exact package name.

Offline

#4 2018-05-11 15:07:30

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,530
Website

Re: List all local packages whose name begins with ...

Please read more than the title of the thread.  Regexes work, but they match against more than just the package name ('provides' was noted in the other thread, and 'groups' seems likely too).

Of course you could also just grep the local database:

grep -lz '%NAME%.gnome' /var/lib/pacman/local/*/desc | cut -d/ -f6

Or sed is better

sed -ns '2{/^gnome/p;}' /var/lib/pacman/local/*/desc

Last edited by Trilby (2018-05-11 15:26:11)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#5 2018-05-11 18:08:34

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: List all local packages whose name begins with ...

pacutils/pacsift really is incredibly nice...

Also if you're directly looking at the files of the local database, you could just match on the filename without using sed or grep.

Last edited by eschwartz (2018-05-11 18:09:54)


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

#6 2018-05-12 21:41:58

Painless
Member
Registered: 2006-02-06
Posts: 233

Re: List all local packages whose name begins with ...

"There's more than one way to skin a cat", as the saying goes

pacman -Qi | grep Name | grep ": gnome"

On the command line this is especially true ...

Offline

#7 2018-05-12 22:42:58

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,530
Website

Re: List all local packages whose name begins with ...

There may be more than one way to skin a cat, but that aint one of them ... unless skinning a cat with a dull toothpick counts.

Piping grep to grep is absurd.  And including the 'i' flag to pacman only to then filter out everything but the name (which would be what'd you get without the 'i' flag) is even more absurd.  If you're going to call it skinning a cat, and it's going to be absurd, you should at least include the cats that you intend to skin:

pacman -Qi | cat | grep Name | cat | grep ": gnome"

EDIT: while I appreciate how graciously my sarcasm was accepted below, if you've been using arch for 12 years, you should really know at least a few of the most common basic options for pacman.  They're not hidden, they're all right there in the man page.

Last edited by Trilby (2018-05-13 10:56:42)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#8 2018-05-12 23:47:11

Painless
Member
Registered: 2006-02-06
Posts: 233

Re: List all local packages whose name begins with ...

Well, I didn't know that the '-Q' flag could be used by itself.  How about:

pacman -Q | grep ^gnome

That's got to be the shortest way to get the required information, surely?

"You learn something new everyday" (as the saying goes, dare I say it)

Thanks - genuinely  smile

Offline

#9 2018-05-13 04:55:38

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: List all local packages whose name begins with ...

If you're going to use two commands (whereas pacsift and Trilby's sed solution both use only one command) then you might as well add -q to your pacman -Q, since pacman Qq will list only the names and not the versions. Theres' no indication that the OP finds the package versions to be interesting for this specific purpose.


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

Board footer

Powered by FluxBB