You are probably backing up your dataâ€”but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.
Become a Premium Member and unlock a new, free course in leading technologies each month.
echo " \"Welcome\" to the most awsome calc evar"
echo "1) Addition" #add two Numbers
echo "2) Subtract" #subtract two numbers
echo "3) Multiply" #multiply two numbers
echo "4) Divide" #divide two numbers
echo "5) Factorial" #Factorial two numbers
echo "6) Campare" #Campare two numbers
echo "7) EXIT" #exit the calculator
read CAL #get number for selection on CALC
while [ $CAL != 7 ]
#if CAL = to 7 will exit, if not continue next line
do
case $CAL in #database arrays
"1")
echo "You've picked Additions"
echo "Choose a number"
read NUM1
echo "Choose a another number to add to the first number"
read NUM2
VALUE=$(($NUM2+$NUM1))
;;
"2") echo "You've picked Subtract"
echo "Choose a number"
read NUM1
echo "Choose a another number to Subtract to the first number"
read NUM2
VALUE=$(($NUM1-$NUM2))
;;
"3") echo "You've picked Multiply"
echo "Choose a number"
read NUM1
echo "Choose a another to multiply"
read NUM2
VALUE=$(($NUM1*$NUM2))
;;
"4") echo "You've picked Divide"
echo "Choose a number"
read NUM1
echo "Choose a another to divide the first number"
read NUM2
VALUE=$(($NUM1/$NUM2))
;;
"5") echo "You've picked Factorial"
read NUM # get a number
FOR=1
FOR=$(($FOR*$NUM)) # FOR TIME NUM
NUM=$(($NUM-1)) # TAKE 1 OFF NUM
FOR=$(($FOR*$NUM)) #FOR TIMES WITH NUM
NUM=$(($NUM-1)) #TAKE 1 OFF NUM
while [ $NUM -gt 1 ] # LOOP UNTIL NUM = 1
do
FOR=$(($FOR*$NUM))
#times End by nu
NUM=$(($NUM-1))
#takes 1 off NUM
done
;;
"6") echo "You've picked Compare"
echo "Pick a number" #ask number
read NUM1 #ask another number
echo "Pick another number"
read NUM2
if [ $NUM1 -eq $NUM2 ] #if NUM1 = NUM2
then
echo "First Number is equal to Second Number" #show anwser NUM1=NUM2
else #or
if [ $NUM1 -lt $NUM2 ] #NUM1 less less than NUM2
then
echo "First Number is less then the Second Number" #show answer A less B
else
echo "First Number is Greater than Second Number" #or answer is A is Greater than B
fi
fi
;;
*)
echo "YOU ENTERED INVAILD OPTIONS"
echo "PLEASE TRY AGAIN"
;;
esac #show answer
echo "The answere is: $VALUE"
read -p "Press Enter to continue..." #pause for answere
clear
#space
echo " \"Welcome\" to the most awsome calc evar"
echo "1) Addition" #add two Numbers
echo "2) Subtract" #subtract two numbers
echo "3) Multiply" #multiply two numbers
echo "4) Divide" #divide two numbers
echo "5) Factorial" #Factorial two numbers
echo "6) Campare" #Campare two numbers
echo "7) EXIT" #exit the calculator
read CAL #get number for selection on CALC
done
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
echo "The answere is: $VALUE"
echo " \"Welcome\" to the most awsome calc evar"
echo "1) Addition" #add two Numbers
echo "2) Subtract" #subtract two numbers
echo "3) Multiply" #multiply two numbers
echo "4) Divide" #divide two numbers
echo "5) Factorial" #Factorial two numbers
echo "6) Campare" #Campare two numbers
echo "7) EXIT" #exit the calculator
read CAL #get number for selection on CALC
while [ $CAL != 7 ]
#if CAL = to 7 will exit, if not continue next line
do
case $CAL in #database arrays
"1")
echo "You've picked Additions"
echo "Choose a number"
read NUM1
echo "Choose a another number to add to the first number"
read NUM2
VALUE1=$(($NUM2+$NUM1))
echo "The answere is: $VALUE1"
read -p "Press Enter to continue..." #pause for answere
;;
"2") echo "You've picked Subtract"
echo "Choose a number"
read NUM1
echo "Choose a another number to Subtract to the first number"
read NUM2
VALUE2=$(($NUM1-$NUM2))
echo "The answere is: $VALUE2"
read -p "Press Enter to continue..." #pause for answere
;;
"3") echo "You've picked Multiply"
echo "Choose a number"
read NUM1
echo "Choose a another to multiply"
read NUM2
VALUE3=$(($NUM1*$NUM2))
echo "The answere is: $VALUE3"
read -p "Press Enter to continue..." #pause for answere
;;
"4") echo "You've picked Divide"
echo "Choose a number"
read NUM1
echo "Choose a another to divide the first number"
read NUM2
VALUE4=$(($NUM1/$NUM2))
echo "The answere is: $VALUE4"
read -p "Press Enter to continue..." #pause for answere
;;
"5") echo "You've picked Factorial"
read NUM # get a number
FOR=1
FOR=$(($FOR*$NUM)) # FOR TIME NUM
NUM=$(($NUM-1)) # TAKE 1 OFF NUM
FOR=$(($FOR*$NUM)) #FOR TIMES WITH NUM
NUM=$(($NUM-1)) #TAKE 1 OFF NUM
while [ $NUM -gt 1 ] # LOOP UNTIL NUM = 1
do
FOR=$(($FOR*$NUM))
#times End by nu
NUM=$(($NUM-1))
#takes 1 off NUM
done
echo "And the answer is $FOR"
read -p "Press Enter to continue..." #pause for answere
;;
"6") echo "You've picked Compare"
echo "Pick a number" #ask number
read NUM1 #ask another number
echo "Pick another number"
read NUM2
if [ $NUM1 -eq $NUM2 ] #if NUM1 = NUM2
then
echo "First Number is equal to Second Number" #show anwser NUM1=NUM2
else #or
if [ $NUM1 -lt $NUM2 ] #NUM1 less less than NUM2
then
echo "First Number is less then the Second Number" #show answer A less B
else
echo "First Number is Greater than Second Number" #or answer is A is Greater than B
fi
fi
read -p "Press Enter to continue..." #pause for answere
;;
*)
echo "YOU ENTERED INVAILD OPTIONS"
echo "PLEASE TRY AGAIN"
;;
esac #end case
clear
#space
echo " \"Welcome\" to the most awsome calc evar"
echo "1) Addition" #add two Numbers
echo "2) Subtract" #subtract two numbers
echo "3) Multiply" #multiply two numbers
echo "4) Divide" #divide two numbers
echo "5) Factorial" #Factorial two numbers
echo "6) Campare" #Campare two numbers
echo "7) EXIT" #exit the calculator
read CAL #get number for selection on CALC
done
#!/bin/bash
function answer
{
echo "The answer is: $1"
read -p "Press Enter to continue..."
}
while true
do
clear
cat <<EOF
"Welcome" to the most awesome calc ever
1) Addition
2) Subtract
3) Multiply
4) Divide
5) Factorial
6) Compare
7) EXIT
EOF
printf "Enter menu option: "
read CAL
case $CAL in
1) echo "You've picked Additions"
printf "Choose a number: "
read NUM1
printf "Choose a another number to add to the first number: "
read NUM2
VALUE1=$(($NUM2+$NUM1))
answer $VALUE1
;;
2) echo "You've picked Subtract"
printf "Choose a number: "
read NUM1
printf "Choose a another number to Subtract to the first number: "
read NUM2
VALUE2=$(($NUM1-$NUM2))
answer $VALUE2
;;
3) echo "You've picked Multiply"
printf "Choose a number: "
read NUM1
printf "Choose a another to multiply: "
read NUM2
VALUE3=$(($NUM1*$NUM2))
answer $VALUE3
;;
4) echo "You've picked Divide"
printf "Choose a number: "
read NUM1
printf "Choose a another to divide the first number:"
read NUM2
VALUE4=$(($NUM1/$NUM2))
answer $VALUE4
;;
5) echo "You've picked Factorial"
printf "Choose the number to factorialize: "
read NUM
FACTORIAL=1
for (( i=$NUM; i>1; i-- ))
do
FACTORIAL=$(( $FACTORIAL * $i ))
done
answer $FACTORIAL
;;
6) echo "You've picked Compare"
printf "Pick a number: "
read NUM1
printf "Pick another number: "
read NUM2
if [ $NUM1 -eq $NUM2 ]
then
echo "First Number is equal to Second Number"
elif [ $NUM1 -lt $NUM2 ]
then
echo "First Number is less then the Second Number"
else
echo "First Number is Greater than Second Number"
fi
read -p "Press Enter to continue..."
;;
7) exit
;;
*) echo "YOU ENTERED AN INVALID OPTION"
echo "PLEASE TRY AGAIN"
read -p "Press Enter to continue..."
;;
esac
done
I Think its working =)The comment after that was from Tintin who did what I suggested and rewrote the script using a function (I said subroutine, basically accomplishing the same outcome). He also contributed to the script with some clean ups as well.
spent a while but it now does what i want it too do thanks for the hints
If you are experiencing a similar issue, please ask a related question
Join the community of 500,000 technology professionals and ask your questions.