I\'m working on a Ubuntu system and currently this is what I\'m doing:
if ! which command > /dev/null; then
echo -e \"Command not found! Install? (y/n)
It seems that nowadays apt-get has an option --no-upgrade that just does what the OP wants:
--no-upgradeDo not upgrade packages. When used in conjunction with install, no-upgrade will prevent packages listed from being upgraded if they are already installed.
Manpage from https://linux.die.net/man/8/apt-get
Therefore you can use
apt-get install --no-upgrade package
and package will be installed only if it's not.