LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   verify if rpm is installed (https://www.linuxquestions.org/questions/linux-newbie-8/verify-if-rpm-is-installed-4175551233/)

apss_evaluator 08-20-2015 03:56 AM

verify if rpm is installed
 
Hi Linux guru's

can you please guide me on how to create a single line command that will tell if the pogi.rpm does not exist it will echo "rpm does not exist" and if it does it will simply output the "rpm -qa | grep pogi"

I have made this, but didn't work

Code:

if [ rpm -qa | grep pogi -eq "" ]; then echo "no pogi installed" else rpm -qa | grep pogi fi

Didier Spaier 08-20-2015 05:31 AM

It wouldn't hurt to learn a bit of shell scripting as this line includes several syntax errors.
http://pubs.opengroup.org/onlinepubs...02.html#tag_18 # the basis
http://tldp.org/LDP/abs/html/index.html # explanations for bash, that is a specific shell with many added features
"man bash" # to be used as a checklist

I advise you to try using only the features provided in the POSIX specification, listed in the first document.

John VV 08-20-2015 06:18 PM

yum will inform you with a "i" it it is installed or not

Code:

su -
yum search pogi

there will "i" if it is installed

unless this is suse
then it is "Zypper"

or it fedora 22 "DNF"

Habitual 08-21-2015 09:06 AM

Code:

rpm -aq | grep pogi > /dev/null
is what I used for this sort of processing.

DarrenDrapkin 08-21-2015 10:35 AM

If 'pogi' is a programme you can use 'which'.
'which pogi' should give you a reply consisting of a file path to the 'pogi' executable.
If you do not have 'pogi' in your system it will reply on the lines of 'no pogi in .....'


All times are GMT -5. The time now is 02:34 AM.