in reply to Re: grep command
in thread grep command

To get the lines and the count (which is what I think the OP wants):

perl -ne 'if (/\bhello\b/) { print; $count++ } END { print "count: $count\n" }' text.out

And if you want to find "hello" regardless of capitalization:

perl -ne 'if (/\bhello\b/i) { print; $count++ } END { print "count: $count\n" }' text.out

Also, grep from the command line doesn't need wc's help:

grep -c hello text.out

It can match regardless of case too:

grep -ic hello text.out