Verifique se um pacote apt-get está instalado e, em seguida, instale-o se não estiver no Linux?

Estou trabalhando em um sistema Ubuntu e atualmente é isso que estou fazendo:

if ! which command > /dev/null; then
   echo -e "Command not found! Install? (y/n) \c"
   read
   if "$REPLY" = "y"; then
      sudo apt-get install command
   fi
fi

É isso que a maioria das pessoas faria? Ou existe uma solução mais elegante?

questionAnswers(21)

yourAnswerToTheQuestion