![]() |
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 |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
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 |
| How to find the first day of previous month in unix? | mohapatra | Shell Programming and Scripting | 10 | 07-02-2007 08:57 PM |
| How to get previous month files | savitha | Shell Programming and Scripting | 7 | 03-23-2006 05:16 AM |
| how to convert from korn shell to normal shell with this code? | forevercalz | Shell Programming and Scripting | 21 | 11-23-2005 02:18 AM |
| file name using previous month | beilstwh | Shell Programming and Scripting | 1 | 08-04-2004 04:21 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
How to get the Previous month in Korn Shell
Hi I have a requirement where i have to append the prev month (e.g Feb for current date ) to the file name before sending it for some other processing.
if input file name is xyz.txt output for the today's run should be xyz_Feb.txt. i tried this code 1 curmth=`date +%m` 2 mth=(Dec Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec) 3 prevmth=${mth[$((curmth - 1))]} 4 echo $prevmth but its giving a syntax error at Line 2 : `(' unexpected. TIA. Regards, naren |
|
||||
|
How to get the Previous month in Korn Shell
Try this.
#!/bin/ksh curmth=`date +%m` set -A mth Dec Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec prevmth=${mth[$((curmth - 1))]} echo $prevmth # end of file # -Ramesh |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|