Understanding 'ongoing monitoring'

Hello - very newbie here.

I have a file that I want to monitor.
Whenever a certain word is added to the end I want to be notified.

I have figured out how to do it manually... ie:

tail /path/to/file/TransferLog.txt | grep Total

When I type this in - I get no output if the word 'Total' is not yet there - and I see the line printed out when it is found.
So far so good.

What I'd like to do is set this 'watching' in motion - have it check every 5 minutes or so until the word 'Total' shows up - then, stop checking and shoot me an email - or other desktop notification (that part I have figured out) - it's the starting and repeating the check that I am unsure how to do.

I am running this on /bin/bash
Thanks for any advice (or keywords to search)

Jeff

tail -f yourfile

OK - didn't realize I could use -f in this way!

I'm trying now to trigger an event when grep finds this line...

#! /bin/bash
if [ tail -f -n 2 /Volumes/Cache-A/TransferLog.txt | grep Total ] ; then
do more stuff
fi 

However - it gives me an error saying that :

line 2: [: missing `]'

Am I allowed to use -f in this way? Or is there something else that I can do to trigger something when it sees the 'Total' in the file?

Thanks,
Jeff

Some parts of the following script are a bit sketchy but the logic should be clear:

#! /bin/bash

pAction()
{
      mail -s "Subject goes here" you@youraddress.com <<-EOT
     Some text
     This is the found line: \"$1\"
     This is some command output: $(date)

     EOT
     return $? 
}



# main()

typeset    chLine=""
typeset    fWatch="/Volumes/Cache-A/TransferLog.txt"

tail -f -n 2 $fWatch | grep "Total" |\
while read chLine ; do
      pAction "$chLine"
done

exit 0

I hope this helps.

bakunin