You are not logged in.

#1 2013-09-22 04:51:31

shallpion
Member
Registered: 2009-12-12
Posts: 65

[solved]pacman output piped to grep with color result?

Hi.  Thanks for reading. I am looking for a command with the following function:

1. It searches only the pacakge name, not the description.
2. However, when a package's name matches the search pattern, it shows the description of this package as well.

After searching in the forum, now I am using something like:

pacman -Ss test_string | grep --color=always -B1 -v '^ ' | less -R

It works nicely in terms of my two requirements. However, I could not get the color output (I have pacman color option) from pacaman even if I used less.

On the contrary, the following command has normal color output

ls --color | grep test_string | less -R 

Did I do anything wrong?

Thanks...

Last edited by shallpion (2013-09-22 04:55:33)

Offline

#2 2013-09-22 04:56:21

shallpion
Member
Registered: 2009-12-12
Posts: 65

Re: [solved]pacman output piped to grep with color result?

I just recall that I have to use --color=always for pacman as well...

Offline

#3 2013-09-22 12:12:50

Mr.Elendig
#archlinux@freenode channel op
From: The intertubes
Registered: 2004-11-07
Posts: 4,097

Re: [solved]pacman output piped to grep with color result?

shallpion wrote:

Did I do anything wrong?

Yes, you are not using expac.

expac -S '%r/%n\n    %d' python
extra/python
    Next generation of the python high-level scripting language
community/pypy3
    A Python3 implementation written in Python, JIT enabled

Note that it will match provides as well as the package name.

Sidenote: kittypack will 'soon' have this feature too, but it uses https://archlinux.org/packages so it is independent of the status of your sync db.

Last edited by Mr.Elendig (2013-09-22 12:21:36)


Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest

Offline

#4 2013-09-22 23:25:47

shallpion
Member
Registered: 2009-12-12
Posts: 65

Re: [solved]pacman output piped to grep with color result?

Mr.Elendig wrote:
shallpion wrote:

Did I do anything wrong?

Yes, you are not using expac.

expac -S '%r/%n\n    %d' python
extra/python
    Next generation of the python high-level scripting language
community/pypy3
    A Python3 implementation written in Python, JIT enabled

Note that it will match provides as well as the package name.

Sidenote: kittypack will 'soon' have this feature too, but it uses https://archlinux.org/packages so it is independent of the status of your sync db.

Sorry I am confused... I know expac but it doesn't look like the function I was looking for... I wanted to search those packages whose *name* contains a string. For example the pypy3 is not what I wanted since it only has "python" in its description...

Offline

#5 2013-09-23 11:07:19

Mr.Elendig
#archlinux@freenode channel op
From: The intertubes
Registered: 2004-11-07
Posts: 4,097

Re: [solved]pacman output piped to grep with color result?

shallpion wrote:

Sorry I am confused... I know expac but it doesn't look like the function I was looking for... I wanted to search those packages whose *name* contains a string. For example the pypy3 is not what I wanted since it only has "python" in its description...

It doesn't search the description, as I said it will also search the 'provides' field. (which pacman -S also does)


Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest

Offline

#6 2013-09-23 11:19:12

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

Re: [solved]pacman output piped to grep with color result?

I'm confused whether this is solved or not.  OP Mr E's answer seems to come very close, yet you didn't prefer it.  But this is marked as solved.  The "color=always" pacman parameter solves the color issue, but pacman -Ss searches descriptions too, which is not what you claimed to want.

If you want to seach package names only, you can use something like

pacman -Ss --color=always python | grep -B1 '^[^ ].*python.*'

Last edited by Trilby (2013-09-23 11:19:54)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#7 2013-09-23 17:46:14

shallpion
Member
Registered: 2009-12-12
Posts: 65

Re: [solved]pacman output piped to grep with color result?

Okay I see, thanks for your (both Mr E and Trilby) replies. I was originally looking for a solution with color output only and later found that I need --color option, so I marked my own question as solved. So far it seems the grep pipe is the only way to search the package name ONLY, so I will stick to it. Thanks again.

Offline

Board footer

Powered by FluxBB