UFW Enable requires y prompt, how to automate with Bash Script?

I'm trying to automate the setup of UFW on an Ubuntu 16.04 instance. However when I type:

sudo ufw enable

I get prompted to enter yes or no, is there a way to feed it yes or set it automatically to start without getting stuck with a prompt?


How about:

$ echo "y" | sudo ufw enable

You could use:

$ sudo ufw --force enable

yes allows you to answer all questions from a program with y.

yes | sudo ufw enable