if ! which command > /dev/null; then
echo -e "Command not found! Install? (y/n) \c"
read -r REPLY
if [ "$REPLY" = "y" ]; then
sudo apt-get install command
fi
fi
-r is used for to avoid interpreting backslashes
Updated the proper condition's with [ ]