Aia has already given you a rather extensive collection of how to tackle this in various script languages and text processing programs. Still, you fall here for one thing most newbies don't take into account. Hence, in the hope to make you aware of a problem you may have already now or maybe only in other similar problems, here it goes:
Your problem is the lack of a definition of what a "word" constitutes. Take, for example, Aias grep
-solution:
grep -iv new lokhtar.example
What this does is to search for lines containing the (-i, case insensitive) sequence n-e-w and filter these lines out (-v). Consider the following lines:
new
bla
Newell
The command will filter out line 1 and 3 but chances are you might only want it to filter line 1. This is because grep
doesn't deal with "words" on an instinctive level like you do, it deals with characters and sequences of characters. And if you want to make it understand what "word" means, you need to tell it.
Here are a few (naive) tries and why they will not always do what they are supposed to do:
1) we could start by adding empty space (blanks or tabs) before and after the word we search for. Instead of "new" we could search for "<blank-or-tab>new<blank-or-tab>". This will work in the middle of a line, but fail if the word is the first or last in a line.
2) look at the following sentences, all containing the word "new" and neither as last nor first word - and still the pattern from 1) would fail to recognize them:
This is new, this is different!
Something new: a word followed by a colon.
Should composites like "new-old" be considered?
Is "new" in quotes still considered the word we look for?
Bottom line: you will have to answer for yourself what exactly you consider to be "the word 'new'" before you can construct an accordig pattern you can search for - whatever you decide can be phrased as regular expression - but you need to decide first, what your decision is.
I hope this helps.
bakunin