I was working on a script to echo the date upon login in a different format but once I get down to echoing the result, it gives me a jumbled up output. I've been searching online to see if I'm calling the variables wrong or using wrong ticks somewhere but no luck. I even have echoed each individual variable before and after the problem echo and they echo the proper date/month/day of week. As my script is right now, it only puts out ". which is a Thu" when run. Also, I've been executing it with "sh ./datescript.sh" Any help/additional resources would be appreciated. Thanks!
My Script:
#!/usr/bin/env bash
date=`date` #NOTE: date being used in two different ways
day=`echo ${date} | cut -f1 -d' '`
month=`echo ${date} | cut -f2 -d' '`
date=`echo ${date} | cut -f3 -d' '`
echo "Today is the ${date}th day of ${month}, which is a ${day}."
echo $day
echo $month
echo $date
dos2unixon it before attempting to run itCRLF, and bash won't interpret those properly as it's looking for UNIX new line charactersLFonly. In notepad++ you can click Edit --> EOL Conversion --> UNIX/OSX Format.date +"Today is the %-dth day of %B, which is a %A."? This is unnecessarily complicated...