Loading...

Conditional check of installed rpm

:heavy_exclamation_mark: This post is older than a year. Consider some information might not be accurate anymore. :heavy_exclamation_mark:

I had to do some scripting. You can query the rpm database with a wildcard pattern. The output is stored in a variable FOUND.

FOUND=$(rpm -qa *econn*)
vinh@foha03:~> echo $FOUND
fo-econn-dev-3.2.7-364.noarch

To check is the search result is empty (-z) or not empty (-n):

vinh@foha03:~> if [ -z "$FOUND" ]; then echo $FOUND; fi
vinh@foha03:~> if [ -n "$FOUND" ]; then echo $FOUND; fi
fo-econn-dev-3.2.7-364.noarch