I'm very new to UNIX coding so please be kind. I am trying to use the date command to obtain the current month's abbreviated name and store it into a variable. I'm using this variable to check against in an if statement to see if it is equal to "Jan" which it should be. I even echo the variable first to test the value and it prints Jan. Unfortunately, the if statement refuses to catch the variable being equal to "Jan" even though it seems as though it is. I have tried using the cut command to select the first 3 characters only to help rule out any trailing white spaces or other format issues. Any ideas why the date function is just not working as expected?
Here is my script:
#! /bin/bash
month= date +"%b"
if[[ $month == "Jan"]]
then
echo The current month, January has 31 days
else
echo Error retrieving month!
fi
I am running it from the terminal on a Ubuntu virtual machine as a bash script.