Write a bash script to check whether the input number is EVEN, ODD or neither EVEN nor
#!/bin/bash
# Reading the number
read -p "Enter a number: " number
# Checking whether the input is the number
if ! [[ "$number" =~ ^[0-9]+$ ]]
then
echo "Neither even nor odd."
# Checking whether the number is even
elif [ $((number%2)) -eq 0 ]
then
echo "Number is even."
else
echo "Number is odd."
fi
Comments
Leave a comment