Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

yes/no

read -p "Is this a good question (y/n)? " answer
case ${answer:0:1} in
    y|Y )
        echo Yes
    ;;
    * )
        echo No
    ;;
esac
Comment

yes/no

read -n 1 -p "Is this a good question (y/n)? " answer
Comment

yes no

inquire ()  {
  echo  -n "$1 [y/n]? "
  read answer
  finish="-1"
  while [ "$finish" = '-1' ]
  do
    finish="1"
    if [ "$answer" = '' ];
    then
      answer=""
    else
      case $answer in
        y | Y | yes | YES ) answer="y";;
        n | N | no | NO ) answer="n";;
        *) finish="-1";
           echo -n 'Invalid response -- please reenter:';
           read answer;;
       esac
    fi
  done
}

... other stuff

inquire "Install now?"

...
Comment

PREVIOUS NEXT
Code Example
Shell :: switch theme in android according to time of day 
Shell :: centos 8 gui 3 
Shell :: git log get out hotkey 
Shell :: clam av debian not installing 
Shell :: django flush sessions on server startup 
Shell :: Can I export fbx files from SpeedTree for UE 
Shell :: como agregar angular material al proyecto 
Shell :: bash pdf merger on mac 
Shell :: ogv to gif linux 
Shell :: how to install wordpress ubuntu 16.04 rosehosting 
Shell :: difference between - and -- in linux 
Shell :: display folder of path linux bashrc 
Shell :: get old commit based on active users 
Shell :: can i create a branch inside of another branch in GIT 
Shell :: get sentence in folder 
Shell :: bash: ./while_loop.sh: bin/bash: bad interpreter: No such file or directory 
Shell :: adb install_failed_already_exists 
Shell :: windows shell delete files based on name 
Shell :: flash non détecté par linux aprés formatage 
Shell :: create ionic v3 project 
Shell :: mac copy big file into clipboard 
Shell :: rename tool numeric linux 
Shell :: cocoapods "iphoneos" cannot be located 
Shell :: bashrc setup "android" example 
Shell :: yaml file example ubuntu netplan error 
Shell :: user alternative php version in cpanel ssh 
Shell :: run same command in different hosts 
Shell :: rm lastUpdated maven 
Shell :: only migarte one table 
Shell :: debug for windows powershell 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =