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)
In Bash:
PKG="emacs" dpkg-query -l $PKG > /dev/null || sudo apt install $PKG
Note that you can have a string with several packages in PKG.