![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
| 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 |
| 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 |
| how to get month last date in unix | rajan_ka1 | Shell Programming and Scripting | 12 | 10-04-2005 07:20 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Formatting Date (adding a month)
i need to write a script that outputs a file with the following format used for its name BRHYYYYMM.TXT. I have no problems creating this file with the current year and month in the title but i would like the month to be the next period i.e. instead of BRH200601.TXT id like BRH200602.TXT. Im unable to pass parameters into the script as its a registered financials appliction script.
Currently have - LOCFNAME="BRH`date '+%Y%m'.TXT" How do i add 1 to the month? i also need to keep it as 2 digits regards dave |
|
||||
|
something better than this should be there,
Code:
# !/usr/bin/ksh m=`date +%m` m=$(($m + 1)) if [ $m -lt 10 ] then m=0$m fi file="BRH`date +%Y`$m.TXT" echo $file exit 0 Last edited by matrixmadhan; 01-18-2006 at 09:47 AM.. |
|
||||
|
i should have kept the sentinels in mind ... but didnt
good catch vino, Code:
# !/usr/bin/ksh m=`date +%m` y=`date +%Y` if [ $m -eq 12 ] then y=$(($y + 1)) m=0 fi m=$(($m + 1)) if [ $m -lt 10 ] then m=0$m fi file="BRH$y$m.TXT" echo $file exit 0 |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|