I have removed the two if statements from before and replaced them with a case statement and tried to remove all the error from the code.
I am trying to run this code but i get an error in the case statement.
"': not a valid identifier
main.sh: line 5: syntax error near unexpected token $'in\r''
case "$y" in "
'ain.sh: line 5:
#!/bin/bash
echo "1. Julian"
echo "2. Gregorian"
read y
case "$y" in
1)echo "Enter your year (1900-2050)"
read x
if [[ $x -ge 1900 && $x -le 2050 ]]
then
a=$((x%19))
b=$((x/100))
c=$((x%100))
d=$((b/4))
e=$((b%4))
g=$(((8*b+13)/25))
h=$(((19*a+b-d-g+15)%30))
m=$(((a+11*h)/319))
j=$((c/4))
k=$((c%4))
l=$(((2*e+2*j-k-h+m+32)%7))
n=$(((h-m+l+90)/25))
p=$(((h-m+l+n+19)%32))
o=$(date +"$x-$n-$p")
echo "Gregorian Easter is on $O."
else
echo "Invalid Input"
fi
;;
2) echo "Enter your year (1900-2050)"
read x
if [[ $x -ge 1900 && $x -le 2050 ]]
then
A=$((x%4))
B=$((x%7))
C=$((x%19))
D=$(((19*C+15)%30))
E=$(((2*A+4*B−D+34)%7))
M=$(((D+E+114)/31))
day=$(((D+E+115)%31))
o=$(date +"$x-$M-$day")
echo "Gregorian Easter is on $o."
else
echo "Invalid Input"
fi
;;
0) exit ;;
esac