Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

Continuous bash script to do tasks again after confirmation

opt=y
while [ $opt = y -o $opt = Y ]
do
        echo -e "Enter first  number: c"
        read -r a

if [ $(bc <<< "$a > 0.0 && $a > 0") ]; then
        result=$(bc <<< "scale=2; $a * $a")
        echo "Square of $a: $result"
else
        echo "Put a number. Nothing else."
fi

echo -e "Want to continue? [y/n] c"
read -r wish

if [ $wish == y -o $wish == Y ]; then
        continue
else
        exit
fi

done
 
PREVIOUS NEXT
Tagged: #Continuous #bash #script #tasks #confirmation
ADD COMMENT
Topic
Name
5+2 =