The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
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 01-26-2008
cml2008 cml2008 is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 12
My theory is that the "printf" command is overriding the second "if" statement.
I have tried to read through the man pages on printf, however that seems to be a bit cumbersome, does anybody know if the "printf" command is overriding my second "if" statement? If so do I have to put in another "printf" command to format the variable "$MNTH" to = 12?
Quote:
if [ $MNTH!=01 ]
then
(( MNTH=$MNTH-01 ))
MNTH=$(printf "%02d" $MNTH)
YEAR=$YEAR
else
if [ $MNTH=01 ]
then
MNTH=12
(( YEAR=$YEAR-1 ))

in red now prints out as such 00/2009

Last edited by cml2008; 01-26-2008 at 11:42 AM.. Reason: grammatical errors