last day of the month

can any one please tell me how can I get the last day of the month
Thanks

Please search the technical FAQ area. If you had, you would have found this page. This has all the links that you need. Check Perderabo's datecalc script. Very fast and very useful.

Thanks for your reply, but I have another question related to month I couldn't find it between FAQ area, the question is can we get the value for month in letters , what I mean if I have the month = Jun can I get it in number like month = 6 ..is there any function do that directly ??
Thanks

You could use case for that:

case $month in
1) month=Jan;;
2) month=Feb;;
:
:

or the other way round:

case $month in
[Jj]an) month=1;;
[Ff]eb) month=2;;
:
:

I am sure there are better ways to do this:

cal `date '+%m'` `date '+%Y'` | grep . | fmt -1 | tail -1

Or to get the last day of every month for a year:

#!/bin/bash

if [ "$1" = "" ]
   then  YEAR=`date '+%Y'`
   else YEAR=$1
fi

MONTH=1
until [ $MONTH -gt 12 ]
      do LASTDAY=`cal $MONTH $YEAR | grep . | fmt -1 | tail -1`
         echo "$MONTH  $LASTDAY"
         let MONTH=$MONTH+1
done

The results look like:
> ./ty
The last day of the month for 2005 is:
1 31
2 28
3 31
4 30
5 31
6 30
7 31
8 31
9 30
10 31
11 30
12 31
> ./ty 2004
The last day of the month for 2004 is:
1 31
2 29
3 31
4 30
5 31
6 30
7 31
8 31
9 30
10 31
11 30
12 31