Is there a way to install and remove packages in a single yum command?
yum shell will allow you to specify multiple commands that will happen simultaneously when
run is entered.
Newer versions of yum also have the
# 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
-y switch to assume yes to confirmation prompts.