in reply to Re^2: how to search for a string in a particular file?
in thread how to search for a string in a particular file?

For more on perl's grep try typing
perldoc -f grep
at your command prompt.

For more on your system grep... well, you'll have to consult man or some other system help.

Update below.

Your code is coming along nicely, but the highly verbose output may be (for a guess) why you want to consider grep.

As written, it will spit out the 'not found' message for each line lacking "icecream" as well as correctly acknowledging those lines where the search pattern exists. There are a couple ways around this.

There are, of course, many other ways to do this, but exploring those ideas should be useful in the long run.