[Solved] wc behaving weirdly

Can anyone explain why wc is behaving weirdly? Their are only 2 occurrences but wc thinks their are 7 occurrences. I have even manually checked this.

$ grep -i base *
lit:         base    xx
lit.lst:003- 00103                            BASE    XX

$ grep -i base * | wc -w                        7

'-w' with wc will give you the number of words in the output
Below is the code for your requirement

grep -i base * | wc -l
1 Like

grep itself can count the matches:

grep -c -i base *

And you can restrict the search to words (e.g. match base but not basement ):

grep -c -i -w base *