Work I have to do is find how many times in this file, appears world 'cat' using command
grep
andwc
.
Tente:
grep -oi cat file1 | wc -l
Exemplo:
$ cat file1
foo cat bar zoo cat
random text cat dog
foobar cat
end!
^ Temos quatro ocorrências de cat
acima.
grep -oi cat file1 | wc -l
4
De man grep
(minha ênfase):
-o, --only-matching Print only the matched (non-empty) parts of a matching line, with each such part on a separate output line.