The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #6 (permalink)  
Old 03-21-2008
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,802
Quote:
Originally Posted by joeyg View Post
Code:
if [[ $month -eq 0 ]] ; then
   let year=$year-1
   let month=1
fi

Shouldn't this be ?

Code:
if [[ $month -eq 0 ]] ; then
   let year=$year-1
   let month=12
fi

January is month 1, so when you subtract 1 you get 0. And you rightly trap for it, decrementing the year but setting the month to 1 for January. I think you should set to 12 for December.
You are right. I was being bombed with other things when I did that... my bad.