having problem while executing the script

Hi i am getting stuck while executing the script in the below line .Please help me out

if [ "$Nam" = "" ];then
  Name=`grep -i $Size $FILE|awk '{print $(NF-1),$NF}' |head -1`
else
  Name="$Nam"       
fi

what is the error you are getting ?

what is there in $Size and $FILE and $Nam ?

 
echo $Size
echo $FILE
echo $Nam
for i in $BATCH_LIST
do
  rm -f file*
  awk '/^-/{close("file"f);f++}{print $0 > "file"f}' $i
  BN=`grep -i ^START file|awk '{print $3}'`
  #echo "\nBatch Name : $BN\n" >> Daily.txt
  FILE_LIST=`ls -l file*|sed '1d'|awk '{print $9}'`
  for FILE in $FILE_LIST
  do
    No=`grep -i Rapport $FILE|awk '{print $2}'`
    Nam=`grep -i output  $FILE|cut -d"/" -f7`
    Size=` grep -i bytes  $FILE|awk '{print $(NF-1)}'|head -1`
    Start_Time=`sed -n '/^0/p' $FILE|head -1`
    End_Time=`sed -n '/^0/p' $FILE|head -2|sed '1d'`
    Result=`grep -i Mailing $FILE|awk '{print $(NF-1),$NF }'`

    if [ "$Result" = "$R1" ];      
    then
      Result="SUCCESS"
    elif [ "$Result" = "$R2" ];
    then
      Result="FAILED"
      echo "$BN  $Name $Start_Time  $End_Time"> t.txt
      awk '{printf "%-20s  %-62s  %-9s %-9s\n",substr($1,1,20),substr($2,1,62),$3,$4}' t.txt >> f.txt
    else
      Result="N/A"
    fi
  done # i am trying to executing the following code but it was halt here in
  if [ "$Nam" = "" ];then
    Name=`grep -i $Size $FILE|awk '{print $(NF-1),$NF}' |head -1`
  else
    Name="$Nam"       
  fi

so can you let me know how to resolve this issue

 
for i in $BATCH_LIST
do
 rm -f file*
 awk '/^-/{close("file"f);f++}{print $0 > "file"f}' $i
 BN=`grep -i ^START file|awk '{print $3}'`
 FILE_LIST=`ls -l file*|sed '1d'|awk '{print $9}'`
 
 for FILE in $FILE_LIST
 do
  No=`grep -i Rapport $FILE|awk '{print $2}'`
  Nam=`grep -i output $FILE|cut -d"/" -f7`
  Size=` grep -i bytes $FILE|awk '{print $(NF-1)}'|head -1`
  Start_Time=`sed -n '/^0/p' $FILE|head -1`
  End_Time=`sed -n '/^0/p' $FILE|head -2|sed '1d'`
  Result=`grep -i Mailing $FILE|awk '{print $(NF-1),$NF }'`
  
  if [ "$Result" = "$R1" ]; 
  then
   Result="SUCCESS"
  elif [ "$Result" = "$R2" ];
  then
   Result="FAILED"
   echo "$BN $Name $Start_Time $End_Time"> t.txt
   awk '{printf "%-20s %-62s %-9s %-9s\n",substr($1,1,20),substr($2,1,62),$3,$4}' t.txt >> f.txt
  else
   Result="N/A"
  fi
 done # here you are closing the second for loop, then how the $FILE and other vairbles will be available ?
 #i am trying to executing the following code but it was halt here in 
 
 if [ "$Nam" = "" ];then
  Name=`grep -i $Size $FILE|awk '{print $(NF-1),$NF}' |head -1`
 else
  Name="$Nam" 
 fi

---------- Post updated at 04:15 PM ---------- Previous update was at 04:12 PM ----------

it will hold the last values of the loop

$Size $FILE $Nam

as you are closing the for loop.