![]() |
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 get the Previous month in Korn Shell | nvuradi | Shell Programming and Scripting | 1 | 03-19-2008 12:31 AM |
| find out month from a date | rudoraj | UNIX for Dummies Questions & Answers | 5 | 07-03-2007 08:21 AM |
| How to get previous month files | savitha | Shell Programming and Scripting | 7 | 03-23-2006 05:16 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 |
|
|
|
||||
|
This should get you closer. Try to check for day=1
Code:
THIS_MONTH=`date +%m`
THIS_YEAR=`date +%Y`
LAST_MONTH=`expr $THIS_MONTH - 1`
if [ $LAST_MONTH = 0 ]
then
LAST_MONTH=12
THIS_YEAR=`expr $THIS_YEAR - 1`
fi
cal $LAST_MONTH $THIS_YEAR | head -3 | tail -2
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|