I'm trying to remove a bunch of packages that have 'abc' in it. However, I don't want to remove 'abc-def'. How can I accomplish this?
For example, how to remove every packages that have 'php' in it, except 'php-common'?
I tried adding --exclude
to the command, but it doesn't work as expected – 'php-common' was still in the deletation list.
# yum --exclude=php-common remove *php*
Loaded plugins: fastestmirror
Resolving Dependencies
--> Running transaction check
---> Package php-cli.x86_64 0:5.4.16-36.el7_1 will be erased
---> Package php-common.x86_64 0:5.4.16-36.el7_1 will be erased
---> Package php-fpm.x86_64 0:5.4.16-36.el7_1 will be erased
---> Package php-mcrypt.x86_64 0:5.4.16-3.el7 will be erased
---> Package php-mysqlnd.x86_64 0:5.4.16-36.el7_1 will be erased
---> Package php-pdo.x86_64 0:5.4.16-36.el7_1 will be erased
--> Finished Dependency Resolution
yum remove *php* !php-common
,--exclude=php-common*
and --exclude=php-common.x86_64 0:5.4.16-36.el7_1
doesn't work either.
I'm asking this because I have a huge package (~1.5 GB) that I still need and don't want to re-download it because my internet is slow.
OS: CentOS 7.
Best Answer
Simply prefix the package name that you want to keep with
-
. You need to add--
before the list of packages to ensure that the name of the package is not treated like an option:From the man page (under the install option):