Hi!
I've got an interesting problem and I'm not sure about how to go about it with grep. Basically, I have a file with 10 million lines which are all numbers:
1
2
3
6
23
42
64
2
1
2
3
I want to count the number of times the pattern "1
2
3" repeats in the file. I figured that grep would be the most efficient way to do this but it seems that if I just grep for "1
2
3", it matches lines containing just 1s or 2s or 3s rather than a complete pattern which I don't understand why. Does anyone know of a solution? Alternatively, I can create the file with spaces instead of newlines but grep basically just gives me a count of 1 because it counts the number of lines containing the pattern rather than the number of patterns in the single line that the file is made of, which is totally useless to me.
So any help would be massively appreciated! Thanks!
Bookmarks