erknrio
10/29/2016 - 5:32 PM

Prompt en bash. FROM: http://stackoverflow.com/questions/226703/how-do-i-prompt-for-input-in-a-linux-shell-script#answer-34354784

do_xxxx=n                      # In batch mode => Default is No
[[ -t 0 ]] &&                  # If tty => prompt the question
read -t 10 -n 1 -p $'\e[1;32m
Do xxxx? (Y/n)\e[0m ' do_xxxx  # Store the answer in $do_xxxx
if [[ $do_xxxx =~ ^(y|Y)$ ]]  # Do if 'y' or 'Y'
then
    xxxx
fi

# [[ -t 0 ]] && read ... => Lee solamente en TTY
# read -t 10 => Tiempo de espera de 10 segundos
# read -n 1 => Espera por un único caracter
# $'\e[1;32m ... \e[0m ' => Print in green
# (readable on both white/black backgrounds)
# [[ $do_xxxx =~ ^(y|Y|)$ ]] => bash regex