I've created a text file with 1000 random uppercase and lowercase letters:
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | head -c 1000 > file1
How many times does the word 'cat' appear in this file, using grep
and wc
?
I did it this way:
grep -ic cat file1
But it counts lines in which it appears, while I want to check how many times it appears in that one line. Any idea?