The UNIX and Linux Forums  


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 -->
  #2 (permalink)  
Old 11-18-2007
Smiling Dragon's Avatar
Smiling Dragon Smiling Dragon is offline Forum Advisor  
Disorganised User
  
 

Join Date: Nov 2007
Location: New Zealand
Posts: 922
Post

It's a bit ugly but:

sh/bash/ksh etc

Code:
month=`date +%m`
day=`date +%M`
year=`date +%Y`

count=13

while [ $count -gt 0 ]
do
    count=`expr $count - 1`
    month=`expr $month - 1`
    if [ $month -lt 1 ]
    then
        month=12
        year=`expr $year -1`
    fi
done

compare_date="${year}${month}${day}"

while <***read the file***>
do
    if [ $DATA_VENCIMENTO -lt $compare_date ]
    then
        <***do stuff***>
    fi
done