Month name


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Month name
# 1  
Old 07-19-2008
Month name

Hi,

Could you pls help me out in finding the name of next month.?

For eg:

date +"%b" gives the current month ie 'Jul'
I want to get the output as 'Aug'

Thanks,
Jerry
# 2  
Old 07-19-2008
With coreutils GNU date:

Code:
date +%b --date '+1 month'

# 3  
Old 07-19-2008
for cal that supports -3 option
Code:
cal -3 |awk 'NR==1{print substr($5,1,3)}'

for systems without GNU date
Code:
date "+%b" | awk 'BEGIN{
 m["Jan"]="Feb"
 m["Feb"]="Mar"
 m["Mar"]="Apr"
 m["Apr"]="May"
 m["May"]="Jun"
 m["Jun"]="Jul"
 m["Jul"]="Aug"
 m["Aug"]="Sep"
 m["Sep"]="Oct"
 m["Oct"]="Nov"
 m["Nov"]="Dec"
 m["Dec"]="Jan"
}
{print m[$0]}
'

# 4  
Old 07-19-2008
If you are using ksh93

Code:
$ printf "%(%B)T\n" "next month"
August

# 5  
Old 07-21-2008
Bug Thanks...!!!

thanks lots for ur help
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need last month files after 10th of every month

Hi, I need all file names in a folder which has date >= 10th of last month, Example : files in folder AUTO_F1_20140610.TXT BUTO_F1_20140616.TXT CUTO_F1_20140603.TXT FA_AUTO_06012014.TXT LA_AUTO_06112014.TXT MA_AUTO_06212014.TXT ZA_AUTO_06232014.TXT Output: AUTO_F1_20140610.TXT... (9 Replies)
Discussion started by: nani1984
9 Replies

2. Shell Programming and Scripting

How to add decimal month to some month in sql, php, perl, bash, sh?

Hello, i`m looking for some way to add to some date an partial number of months, for example to 2015y 02m 27d + 2,54m i need to write this script in php or bash or sh or mysql or perl in normal time o unix time i`m asking or there are any simple way to add partial number of month to some... (14 Replies)
Discussion started by: bacarrdy
14 Replies

3. Shell Programming and Scripting

Convert From Month Number to Month Name

Hi, I have a script that accepts an input date from the user in yyyy-mm-dd format. I need to get the mm-dd part and convert it to month name. example: 2011-11-15 I want that to become "Nov 15" I don't have the GNU date, I am using an AIX os. Thanks. (1 Reply)
Discussion started by: erin00
1 Replies

4. Shell Programming and Scripting

Help with getting last date of previous month and first date of previous 4th month from current date

I have requirment to get last date of previous month and the first date of previous 4th month: Example: Current date: 20130320 (yyyymmdd) Last date of previous month: 20130228 (yyyymmdd) First date of previous 4th month: 20121101 (yyyymmdd) In my shell --date, -d, -v switches are not... (3 Replies)
Discussion started by: machomaddy
3 Replies

5. Shell Programming and Scripting

Script to counting a specific word in a logfile on each day of this month, last month etc

Hello All, I am trying to come up with a shell script to count a specific word in a logfile on each day of this month, last month and the month before. I need to produce this report and email it to customer. Any ideas would be appreciated! (5 Replies)
Discussion started by: pnara2
5 Replies

6. Shell Programming and Scripting

Month Substitution

Team, How do i fetch details of the last day of the month i.e 31st,30th because we receive daily status report but not for the last days of the month.. because when i do an echo `date +%Y%m `${yesterday} it retrieves me 20100631 where as it should have been 20100531.. Hmm interesting!... (4 Replies)
Discussion started by: whizkidash
4 Replies

7. UNIX for Dummies Questions & Answers

print previous month (current month minus 1) with Solaris date and ksh

Hi folks month=`date +%m`gives current month Howto print previous month (current month minus 1) with Solaris date and ksh (7 Replies)
Discussion started by: slashdotweenie
7 Replies

8. Shell Programming and Scripting

Filter by Month

Dear members, I am on sun solaris 9. I am looking for a KSH shell script that will find all log files created at least 3 month ago. The idea is to scan 2 directories and get all log files created at least 3 month ago the present month and create by month and by type (RAP / ARCH ) a TAR... (3 Replies)
Discussion started by: Aswex
3 Replies

9. Shell Programming and Scripting

last month's logfile

hi friends I need a shell script which will do the following Task Enter the month : if you enter 1 then it ll show you last 1 month's (starting from today).log file in the current directry. if you enter 4 then it ll show you last 4 month's (starting from today).log file in the current... (2 Replies)
Discussion started by: deep_kol
2 Replies

10. UNIX for Dummies Questions & Answers

Days of the month

Hello, Please can someone help me in getitng last 7 days from the current date? for eg: input /default : today (10/18/2004) required output: 10/17/2004 10/16/2004 10/15/2004 10/14/2004 10/13/2004 ... (6 Replies)
Discussion started by: Anamika
6 Replies
Login or Register to Ask a Question