Horje
bash user input yes no Code Example
bash user input yes no
### simple yes no question
read -p "Are you sure? " -n 1 -r
echo    # (optional) move to a new line
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
    exit 1
fi

### most widely used method
while true; do
    read -p "Do you wish to install this program?" yn
    case $yn in
        [Yy]* ) make install; break;;
        [Nn]* ) exit;;
        * ) echo "Please answer yes or no.";;
    esac
done

### select from yes/no menu
echo "Do you wish to install this program?"
select yn in "Yes" "No"; do
  case $yn in
    Yes ) make install;;
    No ) exit;;
  esac
done




Shell

Related
flasky fake Code Example flasky fake Code Example
git diff no context Code Example git diff no context Code Example
break a symbolic link in linux Code Example break a symbolic link in linux Code Example
uninstall vlc from terminal Code Example uninstall vlc from terminal Code Example
pip prohibit install without venv Code Example pip prohibit install without venv Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
9