I have wrote a shell script in which I would like to include the functionality to exit the program by pressing the q key. Can I do that?Here is what I currently have:#!/bin/kshecho Press Q to exit \t\t:\cread input if [[ $input = q ]] || [[ $input = Q ]]     then exit 1 else     echo Invalid Input. fi
Exit a program by pressing the key q
shell script;ksh
Use while read input, but due to we want to avoid repeat the echo -en Press Q to exit \t\t:  statement twice, so we better off to use while true instead (a do while variant):xiaobai:tmp $ cat hello.sh #!/bin/kshwhile true; do    echo -en Press Q to exit \t\t:     read input    if [[ $input = q ]] || [[ $input = Q ]]         then break     else         echo Invalid Input.    fidonexiaobai:tmp $ ./hello.sh Press Q to exit                 : appleInvalid Input.Press Q to exit                 : qxiaobai:tmp $ 