Results 1 to 2 of 2
Within a bash script, how can I determine if an RPM is installed? I could parse the output of running the "rpm -q <package" command, but I don't know how ...
- 05-21-2007 #1Just Joined!
- Join Date
- Jun 2006
- Posts
- 32
BASH: Checking for installed RPM
Within a bash script, how can I determine if an RPM is installed? I could parse the output of running the "rpm -q <package" command, but I don't know how to get the output into a variable or something. I don't really wanna' have to send it to a file, and read it.
- 05-21-2007 #2Linux User
- Join Date
- Aug 2006
- Posts
- 458
you could check for return values
or you could grep "not installed"Code:# rpm -q test package test is not installed # echo $? 1 # rpm -q coreutils coreutils-5.93-20 # echo $? 0
if you want to put into variable:
Code:# var=`rpm -q coreutils` # echo $var coreutils-5.93-20 # var=`rpm -q test` # echo $var package test is not installed


Reply With Quote