Answers for "bash prompt user to last input"

0

bash prompt user to last input

checkInputNumber() {
local checker=true
local INPUT
while $checker; do
    read -r INPUT
    if [ -z "$INPUT" ]; then
      echo "$INPUT cannot be blank, please try again"
    elif ! [[ "$INPUT" =~ ^[+-]?[0-9]+.?[0-9]*$ ]]; then
      echo "$INPUT must be a number"
    else checker=false
    fi
done
echo "$INPUT"
return 0
}
Posted by: Guest on October-30-2021

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language