Script to ignore word from a line ...

Hi Gurus,
I'm need of a script in which we are finding an independent word �boy' in a log file. We are using grep in order to do the same. Now in this log file there are some sentences where we see �This is a boy' and we do not want to count word �boy' from this sentence.
So in other word we want to grep only independent word �boy'. We have script for this part but in this script results are not accurate because it is gathering word �boy' from sentence �This is a boy' also.
Is there any way that I can count all word �boy' from sentence �This is a boy' and this count can be subtract from total count of boy?
Thanks in advance.
Hey

Are you simply looking for instances where the word boy exists alone on a line?
Thus:
example-->

boy
this is is boy
this is a girl
boy oh boy

>>is count of 1 (one)

And, what is your current command that is not working correctly?

Using either "sed" or cascaded "grep"s (one "grep" piping its output into another "grep") you could first match all lines containing "boy" and then filter out from the resulting set all lines containing "This is a boy." For instance:

sed -n '/boy/ {
          /This is a boy\./ !p
          }' /path/to/inputfile

Alternatively, cascaded "grep"s (which will be slower than the first solution):

grep 'boy' /path/to/inputfile | grep -v 'This is a boy\.'

Counting the lines printed this way is left as an exercise to the reader. ;-))

I hope this helps.

bakunin