The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Help, I need to get the last date of previous month sirrtuan Shell Programming and Scripting 11 10-14-2008 05:59 AM
last month end date vanathi UNIX for Advanced & Expert Users 7 03-21-2008 04:17 PM
How do I set my date in a unix script to 'new month Agent704 UNIX for Dummies Questions & Answers 1 01-27-2008 01:58 PM
Use date command to find last month Cbish68 Shell Programming and Scripting 5 08-10-2007 10:32 AM
find out month from a date rudoraj UNIX for Dummies Questions & Answers 5 07-03-2007 08:21 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-29-2005
rajan_ka1 rajan_ka1 is offline
Registered User
  
 

Join Date: Sep 2005
Posts: 130
how to get month last date in unix

Hello

I want to get end date of the any month in unix . is there any function to do this.


we can get month from date command 'date +%b'
example:

If Feb month then last date is 28

if sep then last date 30. like this


thanks

please help
  #2 (permalink)  
Old 09-29-2005
monsanbu monsanbu is offline
Registered User
  
 

Join Date: Sep 2005
Location: Chennai,India
Posts: 12
Try this command
You can include this in a shell script to get the month and year to pass to the below command.

cal 10 05 | grep -v ^$ | tail -1 | sed 's/^.* \([0-9]*\)$/\1/'

Last edited by monsanbu; 09-29-2005 at 05:39 AM..
  #3 (permalink)  
Old 09-29-2005
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,944
try this,

cal <month> <year> | sed '/^$/d' | tail -1 | awk '{printf $NF}'
  #4 (permalink)  
Old 09-29-2005
rajan_ka1 rajan_ka1 is offline
Registered User
  
 

Join Date: Sep 2005
Posts: 130
no use

not working

please check once again.

thanks
  #5 (permalink)  
Old 09-29-2005
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,796
Why dont you use the datecalc.

It does exactly what you require.
  #6 (permalink)  
Old 09-29-2005
monsanbu monsanbu is offline
Registered User
  
 

Join Date: Sep 2005
Location: Chennai,India
Posts: 12
Which solution is not working? Give the last two digits for year
  #7 (permalink)  
Old 09-29-2005
vgersh99's Avatar
vgersh99 vgersh99 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,119
Code:
echo $(cal 10 2005) | awk '{print $NF}'
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:04 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0