[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Counting occurances of a word in a file.



On Fri, 09 Dec 2011 12:34:45 +0100, Jörg-Volker Peetz wrote:

> Yes, you are right. My suggestion doesn't work if a word appears more
> than once in a line since only lines which contain the word are counted.
> Sorry for the confusion.

PMFJI. Never mind; *I'm* glad you mentioned it anyway. I have a script 
which needs just the count of lines containing something, and hitherto 
grepped the file and then piped the result into wc -l.

I have now changed it to use grep - c instead. Saves a process, and is 
more elegant.

Thanks!


Reply to: