I am facing one problem with date command.Actually I want to use this command to get the last month,not the current month..OK,I can do current month - 1 and give special condition for january,But this time i need last month as strings like January,februaury,march etc...
There is option available to get the month in the string form and that is
`date +%B` but this will give you the current month.
I can definitely do what i want with 12 cases one for each month but i want to avoid that.Please help me if anyone has any idea to implement this with out using 12 conditions.
Thanks grumpf,
Actaully i was looking for some similar options if i could..But the problem is I am using SunOs 5.8 and i am not authorized to add any package to the server.I tried this command and it didn't work..
It seems you have done lot of stuff on date command,Can you tell me is there any way to use date command to read from some variable not from the system,I mean if i can give my inputs to date command with out disturbing any system configurations?
set -A YEAR January February March April May June July August September October November December
MONTH=$(date +%m)
if (( ${MONTH} == 1 )); then
MONTH=11
else
let MONTH=${MONTH}-2
fi
echo "This month is July, so last month was "${YEAR[${MONTH}]}