Reputation: 33
In my script i need to get the first day and last day of previous month. the format should be like for April month:
1-April-2014 30-April-2014
I am very new to unix please help me
Thanks in advance
Upvotes: 1
Views: 2214
Reputation: 195049
I assume you have gnu date, then check the following:
kent$ date -d"1 $(date -d'last month' +%b)" +%F
2014-04-01
kent$ date -d"-1 day 1 $(date +%b)" +%F
2014-04-30
Upvotes: 3