Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to get last day of a month 3

Status
Not open for further replies.

dendenners

Programmer
Jul 17, 2001
110
IE
Hi,
I want a shell script function that will take in a month number as an argument and return the last day of that month. I can assume for leap years that the incoming month is in the system's current year. This will not be difficult to do, but I can't think of a concise way to do it. Can anyone else?
Thanks
 
You could try this:
Code:
month=7
cal $month `date +%Y` | awk '/./{day=$NF};END{print day}'
It works with my version of 'cal'.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top