Test if today is monthend eg: 28th,30th or 31

Sun microsystems Sun fire v20z amd opter...
October 27, 2010 at 03:47:19
Specs: Linux Red Hat, 2gb/4gb
I Have come up a script that will check if today is the 31st, But i am not sure how to add 28th or 30th of the month;

see my script:

DATE=`date +%d`
while true;do
if [ $DATE -ne "31" ] ; then
echo "Today Is not Monthend"
echo "Today Is Monthend you can continue..."

thanks for any help

See More: Test if today is monthend eg: 28th,30th or 31

October 27, 2010 at 06:36:44
Look at the man page for 'date'.


date -d tomorrow +%d

should give you a "1".

Report •

October 27, 2010 at 10:17:15
You can also parse the cal command in numerous ways. This prints the last day of the current month:

cal|awk ' { print $NF } '| sed '/^$/d' |tail -1

A better shell programmer than I might come up with a more efficient algorithm.

Report •

October 28, 2010 at 00:00:29
Thanks will give it a shot,

Report •
Related Solutions

Ask Question