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 05:20 AM
changing the format of date nasirgondal Post Here to Contact Site Administrators and Moderators 1 06-08-2006 02:37 AM
How to print current month - 1 in string format mogli4 Shell Programming and Scripting 3 03-10-2006 04:47 PM
Changing date format Sabari Nath S Shell Programming and Scripting 5 12-07-2005 03:38 AM
Changing the date format Dream86 Shell Programming and Scripting 10 06-08-2005 02:35 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-19-2008
marringi marringi is offline
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?
  #2 (permalink)  
Old 05-19-2008
Yogesh Sawant's Avatar
Yogesh Sawant Yogesh Sawant is offline Forum Staff  
Part Time Moderator and Full Time Dad
  
 

Join Date: Sep 2006
Location: Rossem, Tazenda
Posts: 1,086
don't know about todays moth, but to get the current month:
Code:
echo _`date '+%m'`_

  #3 (permalink)  
Old 05-19-2008
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,342
Or:


Code:
date "+_%m_"

Read the man page how to format the date string.
  #4 (permalink)  
Old 05-19-2008
joeyg's Avatar
joeyg joeyg is offline Forum Staff  
modérateur
  
 

Join Date: Dec 2007
Location: Home of 17-time world champion Boston Celtics
Posts: 1,311
Wink


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

_05_

  #5 (permalink)  
Old 05-19-2008
marringi marringi is offline
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..
  #6 (permalink)  
Old 05-19-2008
joeyg's Avatar
joeyg joeyg is offline Forum Staff  
modérateur
  
 

Join Date: Dec 2007
Location: Home of 17-time world champion Boston Celtics
Posts: 1,311
The following will assign the month as a number to a variable.


Code:
> curr_mth=$(echo "_"$(date '+%m')"_")
> echo $curr_mth
_05_
>

  #7 (permalink)  
Old 05-19-2008
marringi marringi is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 36
Is it not possible to have it somehow in this format:


Code:
my $month=echo(""_"$(date '+%m')"_"");

?
Closed Thread

Bookmarks

Tags
date

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 12:27 AM.


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