方法1
if [ -x "$(command -v ufw)" ]; then
echo "ufw installed!"
else
echo 'Error: git is not installed.' >&2
exit 1
fi
方法2 (与OS的发行版本有关)
if [[ $(apt list ufw) =~ "installed" ]]; then
echo "ufw installed"
else
echo "Error: ufw install failed!"; exit
fi