The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
changing format shary Shell Programming and Scripting 4 01-31-2008 02:20 AM
changing the format of date nasirgondal Post Here to Contact Site Administrators and Moderators 1 06-07-2006 10:37 PM
How to print current month - 1 in string format mogli4 Shell Programming and Scripting 3 03-10-2006 01:47 PM
Changing date format Sabari Nath S Shell Programming and Scripting 5 12-07-2005 12:38 AM
Changing the date format Dream86 Shell Programming and Scripting 10 06-08-2005 10:35 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 05-19-2008
Registered User
 

Join Date: Mar 2008
Posts: 36
Getting month and changing format

Hello,

I would like to get todays moth and write it in this format: _06_

Any ideas?
Reply With Quote
Forum Sponsor
  #2  
Old 05-19-2008
Yogesh Sawant's Avatar
Part Time Moderator and Full Time Dad
 

Join Date: Sep 2006
Location: Rossem, Tazenda
Posts: 798
don't know about todays moth, but to get the current month:
Code:
echo _`date '+%m'`_
Reply With Quote
  #3  
Old 05-19-2008
Moderator
 

Join Date: Feb 2007
Posts: 2,328
Or:

Code:
date "+_%m_"
Read the man page how to format the date string.
Reply With Quote
  #4  
Old 05-19-2008
joeyg's Avatar
Moderator
 

Join Date: Dec 2007
Location: Home of world champion Boston Celtics
Posts: 983
Wink

Code:
echo "_"$(date '+%m')"_"

_05_
Reply With Quote
  #5  
Old 05-19-2008
Registered User
 

Join Date: Mar 2008
Posts: 36
I meant the current month... Didn't make myself clear...

I want to use it in a link, so that say the month is January, _01_ is written into the link..
Reply With Quote
  #6  
Old 05-19-2008
Registered User
 

Join Date: Mar 2008
Posts: 36
Quote:
Originally Posted by joeyg View Post
Code:
echo "_"$(date '+%m')"_"

_05_
Thanks for the quick response. I'm a no good programmer. How would you use this...

I tried:

Code:
my $month=echo(""_"$(date '+%m')"_"");
with no luck...?
Reply With Quote
  #7  
Old 05-19-2008
joeyg's Avatar
Moderator
 

Join Date: Dec 2007
Location: Home of world champion Boston Celtics
Posts: 983
The following will assign the month as a number to a variable.

Code:
> curr_mth=$(echo "_"$(date '+%m')"_")
> echo $curr_mth
_05_
>
Reply With Quote
Google The UNIX and Linux Forums
Reply

Tags
date

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 07:57 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0