I was given access to a server with 50+ php rpms installed. I'm trying to remove them all.
Basically, I'm trying to combine these two commands:
rpm -qa | grep 'php'
and
rpm --erase
I know a little about pipes and redirection, but I don't see how to use them for this purpose. Please help.
yum
List and remove the indicated packages and all their dependencies, but with a y/N
confirmation:
yum remove 'php*'
To bypass the confirmation, replace yum
with yum -y
.
rpm
This section builds upon the answers by twalburg and Ricardo.
List which RPMs are installed:
rpm -qa 'php*'
rpm -qa | grep '^php' # Alternative listing.
List which RPMs which will be erased, without actually erasing them:
rpm -e --test -vv $(rpm -qa 'php*') 2>&1 | grep '^D: erase:'
On Amazon Linux, you may need to use grep '^D: ========== ---'
instead.
If the relevant RPMs are not listed by the command above, investigate errors:
rpm -e --test -vv $(rpm -qa 'php*')
Erase these RPMs:
rpm -e $(rpm -qa 'php*')
Confirm the erasure:
rpm -qa 'php*'