3

I have a different scenario. To make it more clear here is what I want.

I've a file named myfile with following info:

Saurav Kumar
    Sumeet Kumar
Punit Kumar Sharma
      Supreet Prasad Sinha
  N. Senthil Kumar
 A. Salai Nayagan
.
.

and so on..

Now If I want to get the names which have Kumar as a part, I can use simply:

grep -i "kumar" myfile

So it will return like this:

Saurav Kumar
    Sumeet Kumar
Punit Kumar Sharma
  N. Senthil Kumar

What I want is not to display the word Kumar in the search result. i,e the searched results without Kumar like this:

Saurav
    Sumeet
Punit Sharma
  N. Senthil

One more thing I have to use only grep to get the result not any thing else like tr, sed, awk, etc..

I don't know whether my question heading is appropriate or not. So I request to change it to make it more meaningful.

I will be very happy to get the solution.

Thanks in advance!!

4

2 に答える 2