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 :: use -i 
Shell :: switch theme in android according to time of day 
Shell :: git ventoy 
Shell :: push changes to github phpstorm 
Shell :: connecting to timescaledb from terminal 
Shell :: réinstaller interface graphique debian 
Shell :: how to check if cyberduck is installed 
Shell :: how to do a sudo reboot on raspberry pi 
Shell :: how to calculate longitude delta 
Shell :: drush confi set with laguage 
Shell :: how to get rid of the start up screen on your pyinstaller .exe file 
Shell :: vant github 
Shell :: react-laag 
Shell :: list all audio files with duration bash ffprobe 
Shell :: wget code 
Shell :: fatal authentication failed for git psuh 
Shell :: bash silent errors 
Shell :: rm bash 
Shell :: powershell tab (bash style) 
Shell :: kubernetes get crd and their namespaces 
Shell :: how to install lshellchecck in linux 
Shell :: harmony patch download 
Shell :: toggle button github md 
Shell :: how to migrate from yarn to npm 
Shell :: how do you run a lisp file with sbcl 
Shell :: msbuild is not recognized as the name of a cmdlet 
Shell :: wise highlight ubuntu 
Shell :: nuget system.web.http.webhost 
Shell :: containing globalprotect, pre-dependency problem: globalprotect pre-depends on libqt5webkit5 libqt5webkit5 is not installed. 
Shell :: accept input linux 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =