UNIX awk pattern matching and printing lines

I have the below plain text file where i have some result, in order to mail that result in html table format I have written the below script and its working well. cat result.txt
Page 2015-01-01 2000
Colors 2015-02-01 3000
Landing 2015-03-02 4000

  #!/bin/sh LOG=/tmp/maillog.txt RES=/tmp/result.txt  html_log () { awk ' BEGIN {  print "<html><body><table border=1 cellspacing=0 cellpadding=3>" print "<tr>" print "<td><b>Metric</b></td>"; print "<td><b>Date</b></td>"; print "<td><b>count</b></td>"; print "</tr>" } { print "<tr>" print "<td>"$1"</td>"; print "<td>"$2"</td>"; print "<td>"$3"</td>"; print "</tr>" } END { print "</table></body></html>" } ' $RES >> $LOG }  #Function for sending mails dd_mail () { ( echo "From:xyz " echo "To: xyz" echo "MIME-Version: 1.0" echo "Subject: Emp rpt"  echo "Content-Type: text/html"  cat $LOG ) | sendmail -t  html_log dd_mail  exit 0 

Now the problem is very rarely these 3 metrics are repeating (refer below), if it repeats i want to identify and generate the separate html table so that when i send email to users they can see 2 separate html tables.

cat result.txt Page 2015-01-01 2000 Colors 2015-02-01 3000 Landing 2015-03-02 4000 Page 2015-01-01 1000 Colors 2015-02-01 2000 Landing 2015-03-02 9000 I tried pattern matching and print the lines but none of my idea's worked could someone help me on this.

Thanks

How do you identify the end of the first and the start of the second table? Always three lines? Always "Page" in the first line?

---------- Post updated at 12:50 ---------- Previous update was at 10:41 ----------

Try

awk '
/Page/  {print "<html><body><table border=1 cellspacing=0 cellpadding=3>"
         print "<tr>"
         print "<td><b>Metric</b></td>"
         print "<td><b>Date</b></td>"
         print "<td><b>count</b></td>"
         print "</tr>"
        }

        {print "<tr>"
         print "<td>"$1"</td>"
         print "<td>"$2"</td>"
         print "<td>"$3"</td>"
         print "</tr>"
        }

/Land/  {print "</table></body></html>"
        }

' file