[CentOS] Strange behavior from grep

Fri Mar 28 13:56:02 UTC 2008
Bob Beers <bob.beers at gmail.com>

On Fri, Mar 28, 2008 at 9:37 AM, Mário Gamito <gamito at gmail.com> wrote:

> Well, my question now is, how do I get the word 'gamito' alone from the
> file ?
>
> Any help would be appreciated.
>
>
What are you really trying to do?

grep 'gamito' file and
grep -c 'gamito' file   will tell you if it is present.
grep -n 'gamito' file   will tell you which line(s) it is on.
grep -o 'gamito' file   only gives you the word 'gamito' is in or not.
grep -C3 'gamito' file   should give 3 context lines

There are also sed and awk commands which might be useful.
But the real answer depends on what you will do with the info.

-Bob
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.centos.org/pipermail/centos/attachments/20080328/d9030aae/attachment-0005.html>