Use regex in zypper

Is it possible to use regex in zypper? The reason I asked this is because sometimes zypper se lists too many packages and reading through them is annoying. It would be nice if I could just search for a regex and zypper could recognize them and substitute as needed. I know you can use awk and do stuff like this (thanks Jetchisel):

awk '$2 ~ /^name$/' < <(zypper se name)

But this is ‘ugly’ and it would be great if you could do it with just zypper. So any way to do it? :slight_smile:

I should say the man page of zypper shows many options to refine a search. Wildcards are mentioned, case sensitivety, match-all/any/substrings/words/exact. Does this realy n provide you witjh thh wanted output?

My man page (13.1) says

If the search string is enclosed in ‘/’, for example $ zypper se ‘/^k.*e$/’, it’s interpreted as a regular expression.

And “zypper se -h” says

If a search string is enclosed in ‘/’, it’s interpreted as a regular expression.

But it doesn’t seem to work ->

The -h option is not in the 12.3 man page.

Thus we have again a case were potential helpers are left in distress because the OP does not tell which version of openSUSE he uses.>:)

Shoot sorry, I made it at like 2 am, wasnt thinking clear, I use 13.1.

But thank you I will try it out.

Edit: And it works, thank you both so much, I did try reading the manpage but probably wasnt thinking straight and missed it.

Run this on your 13.1
man zypper | grep regex

man zypper | awk ‘/regex/’

and then enjoy reading the output rotfl!

jetchisel@OSSE:~> man zypper | grep regex
<standard input>:1001: warning: numeric expression expected (got )') <standard input>:1003: warning: numeric expression expected (got )‘)
<standard input>:1010: warning: numeric expression expected (got )') <standard input>:1027: warning: numeric expression expected (got )’)
<standard input>:1032: warning: numeric expression expected (got )') <standard input>:1036: warning: numeric expression expected (got )‘)
<standard input>:1045: warning: numeric expression expected (got )') <standard input>:1054: warning: numeric expression expected (got )’)

Any idea why this happens? I tried the term ‘search’ on the zypper man page and it gave me this SUSE Paste. I also tried these two commands and they worked fine with no error.

man bash | grep regex
man bash | grep 'search'

It seems to be something with the zypper man page, any idea what it could be?

Strange indeed.

It is not the grep, but the man command that generates those messages. It only generates them when the output is not formatted for the terminal.

henk@boven:~/test> man zypper >stdout 2>stderr
henk@boven:~/test> cat stderr
<standard input>:937: warning: numeric expression expected (got `)')
&lt;standard input&gt;:939: warning: numeric expression expected (got `)')
<standard input>:946: warning: numeric expression expected (got `)')
&lt;standard input&gt;:961: warning [p 16, 0.8i]: cannot adjust line
&lt;standard input&gt;:963: warning: numeric expression expected (got `)')
<standard input>:968: warning: numeric expression expected (got `)')
&lt;standard input&gt;:972: warning: numeric expression expected (got `)')
<standard input>:980: warning [p 16, 5.0i]: cannot adjust line
<standard input>:981: warning: numeric expression expected (got `)')
&lt;standard input&gt;:990: warning: numeric expression expected (got `)')
<standard input>:998: warning [p 16, 9.0i]: cannot adjust line
<standard input>:1000: warning [p 16, 9.3i]: cannot adjust line

Note that I have done this on openSUSE 12.3, thus the man page is different from the 13.1 one, thus the line numbers are different, but the problem is the same.

Some how i am not convince that it is the man command that generates this error but zypper man page or zypper it self. (someone correct me if im wrong.)

man bash >stdout 2>stderr 
cat stderr

man sed >stdout 2>stderr 
cat stderr

And other executables that i have tried does not produce the same error, so alanbortu]( dig some more and file this bug so that Geeko can eat it already! :wink:

One thing is for sure, it is not zypper itself. That program is not run when you consult it’s man page.

It is man that protests at the conversion of the man file through the ASCII driver. That is the one that does not care for bold, etc output when it runs on a VT100/ASCII type of terminal (like konsole). That means IMHO wrong formatting in that file.

Man generates the text because it find these lines in the zypper man page.

.TP ============================================================================

I don’t speak groff, but Man usage - The GNU Troff Manual doesn’t say anything about non numeric expressions after “.TP”. Yes, please, feel free to open a bug report.

I will be happy to do it. Let me know if I did it wrong