Bash, cómo hacer una pregunta y responder acorde en un script

From Wiki de Flat Estrategia Digital
Jump to: navigation, search
echo 'Pregunta? (s/N)'
read runCommandQuestion
# Next line sets default value to 'N' to avoid warnings in the if
[ -z $runCommandQuestion ] && runCommandQuestion=N
if [ $runCommandQuestion == "y" ] || [ $runCommandQuestion == "Y" ]
    then
        runCommand=y;
    else
        echo 'Doing nothing...'
        exit 1
fi

Facebook Comments