Getting month and changing format


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Getting month and changing format
# 1  
Old 05-19-2008
Getting month and changing format

Hello,

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

Any ideas?
# 2  
Old 05-19-2008
don't know about todays moth, but to get the current month:
Code:
echo _`date '+%m'`_

# 3  
Old 05-19-2008
Or:

Code:
date "+_%m_"

Read the man page how to format the date string.
# 4  
Old 05-19-2008
Hammer & Screwdriver

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

_05_

# 5  
Old 05-19-2008
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  
Old 05-19-2008
Quote:
Originally Posted by joeyg
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...?
# 7  
Old 05-19-2008
The following will assign the month as a number to a variable.

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

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to get last 12 month date in YYYY.MM format?

I need the date format in YYYY.MM format and I am able to get current month date as well as previous month date with below command PM=`date +'%Y.%m' -d 'last month'` CM=`date +'%Y.%m' -d 'now'` but I need to get YYYY.MM date format for previous 12 months so could you please help me how I get... (2 Replies)
Discussion started by: Amit Joshi
2 Replies

2. Shell Programming and Scripting

Help with shell script on Month Changing Logic

Hi Unix Experts, Happy Morning to all !! :) I am new to UNIX Shell Scripting and at my begineer level. To get acquainted to scripting, I am trying to create a script. The details/requirements of my script was to create a script with month changing logic in it so that on every 6th Working... (3 Replies)
Discussion started by: micky3112
3 Replies

3. Shell Programming and Scripting

How to convert date format such as 7/18/2015 to the number of month

How to convert date format such as 7/18/2015 to the number of month from requesting date 'date' in sh scripting ? Let say I have output in my log.txt -> 7/18/2015. How I convert it to the full number of month starting from 'date' till 7/18/2015 in shell scripting ? Thanks in advance. (1 Reply)
Discussion started by: amerabest
1 Replies

4. Shell Programming and Scripting

How to Find number of days in a month in mmddyyyy format?

Hi Guru's, I am working on a shell script from past a month and unable to get rid of automating while working with dates,here's what i have. inital_date=11012011 final_date=11302011 expected_output= has to be in below format PFB 11012011 11022011 11032011 * * * 11102011 * *... (9 Replies)
Discussion started by: Gaurav198
9 Replies

5. UNIX for Dummies Questions & Answers

how to fetch month format files in a file

I have files like pra.01 sra.02 see.03 swc.03 sre.04 after dot it contain month format when ever user type "01" month i have to fetch what are 01 files to come (2 Replies)
Discussion started by: sgoud
2 Replies

6. AIX

Convert unix timestamp to year month day format ?

Hello, How do I convert unix timestamp value to 'normal' date format - to get year month and day values ? Looks like it's easy to do using GNU date (linux systems). But how do I do tthis on AIX ? I don't want to write C program, any ways to do that using unix shells ? thanks (1 Reply)
Discussion started by: vilius
1 Replies

7. Shell Programming and Scripting

script for month conversion in numeric format

Hi Experts, How to convert months into numeric format with the help of some script: Suppose I want: " Jan | Feb | Mar | Apr | May | Jun | Jul | Aug | Sept | Oct | Nov | Dec " to be converted as : " 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 " Thanks in... (2 Replies)
Discussion started by: rveri
2 Replies

8. Shell Programming and Scripting

Get yesterday's date in year-month-day format?

Dear All, Actually, i'm doing some reporting job and i need to pass yesterday's date in Year-Month-Day format(e.g. 2009-06-10) to another program for generating 2009-06-10 report. to get today's date, it's easy to just date '+%Y%m%d' , but no idea how can i get this kind of format for... (2 Replies)
Discussion started by: tiger2000
2 Replies

9. Shell Programming and Scripting

changing month in Mmm format to mm FORMAT

i have an variable mydate=2008Nov07 i want o/p as in variable mymonth=11 (i.e nov comes on 11 number month) i want some command to do this for any month without using any loop. plz help me (1 Reply)
Discussion started by: RahulJoshi
1 Replies

10. Shell Programming and Scripting

How to print current month - 1 in string format

I need to get the current month -1 in string format, like Feb-2006. I am using k shell. Any help is appreciated. (3 Replies)
Discussion started by: mogli4
3 Replies
Login or Register to Ask a Question