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 -->
  #7 (permalink)  
Old 02-05-2007
ozzman ozzman is offline
Registered User
  
 

Join Date: Feb 2007
Location: Aus Syd
Posts: 10
Thanks for the reply

the part that take the most of the time is the following code.


Code:
  
function line_count
   {
       COUNT=`echo $1 | awk -F\| '{print NF}'`
       if [ "$COUNT" != "$2" ]
       then
          error_log "File $FN: Validation failed at line   $LINENUM. Expected $2, getting $COUNT"
          return 5
       fi
   }

   function validate_line
   {
        if [ "$1" = "$FIRST_LEVEL_HEAD" ]
        then
              line_count "$2" $FIRST_LEVEL_COUNT
              return $?
        elif [ "$1" = "$SECOND_LEVEL_HEAD" ]
        then
              line_count "$2" $SECOND_LEVEL_COUNT
              return $?
        else
              error_log "File $FN: Line $LINENUM head is not regconised"
              return 5
        fi
   }


   function validate_file
   {
      trace_log "Start to validate $FN..."
      LINENUM=0
      ERROR=0
       while read LINE
       do
            LINENUM=`expr $LINENUM + 1`
            LINE_HEAD=`echo $LINE | awk -F\| '{print $1}'`
            validate_line $LINE_HEAD "$LINE"
            if [ ! $? -eq 0 ]
            then
               ERROR=1
            fi
       done < $1
       if [ ! $ERROR -eq 0 ]
       then
           return 7
       fi
    }


    validate_file $FILE


Any suggestion ?