2

we want to check if following rpm's version are installed , so we did as:

rpm -qa | egrep -c 'python-argcomplete-0.3.7-1|postgresql-libs-9.2.13-1.el7_1.x86_64'

since higher version of postgresql-libs can also installed as - postgresql-libs-9.2.19-1.el7_1.x86_64

then we try to capture both versions as following but without success

 rpm -qa | egrep -c 'python-argcomplete-0.3.7-1|postgresql-libs-9.2.[^0-9]-1.el7_1.x86_64'

expected results should be 2 but we get 1

1 Answer 1

4

[^0-9] matches any character outside 0-9, so your regex won’t match any package version you’re likely to encounter. If you want to match 13 or later, you’d need (1[3-9]|[2-9][0-9]) (assuming the last component of the version won’t reach 100).

You could ask rpm directly:

rpm -q python-argcomplete-0.3.7 'postgresql-libs-9.2.*'

This will match any 9.2 version of postgresql-libs, which might not be exactly what you’re after, but in many cases it should be good enough.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .