Operating System - Linux
1753864 Members
7792 Online
108809 Solutions
New Discussion

Re: counting the number of times a word appears in a file

 
SOLVED
Go to solution
Sandman!
Honored Contributor

Re: counting the number of times a word appears in a file

James,

If "cnt" is declared in the BEGIN section of the awk construct then I don't know why it needs to be set equal to 1 and if it's defined in the ACTION section, then every new line read would clobber its contents and reset it back to 1. Could you share the awk construct you used to get the correct result?

Maybe I'm not able to understand your requirements.

thx