Is there a way to install and remove packages in a single yum command?
Yes. Invoking yum shell
will allow you to specify multiple commands that will happen simultaneously when run
is entered.
Newer versions of yum also have the swap
command:
# yum swap -- install foo -- remove bar
As the accepted answer already says, you can use yum shell
to run multiple commands at once, which is fine for interactive use. But if you want to invoke this command from a script, you can also run it against a file, eg yum shell translist.txt
, where the file could contain, for example:
remove squid
install squid34
run
Append the -y
switch to assume yes to confirmation prompts.