date question

hi,

how do i get the last day of the current date or a given date using unix.

for e.g. if i run the command/script on 1st feb 2002 i should get 28 th feb 2002.

thanks !!
AnkuR.

I have just revised my datecalc script to add this function. Click here for datecalc.

Nice! I would also suggest using Perl so that the function/module can be readily called directly from other scripts.

Just like everything else in Unix (and perl), there is more than one way to do it. If you are using GNU date, then:

date +%x --date="`date --date=\"month\" +%b` 1 day ago"

will give you the last day of the month.