I'm trying to get the number of matches (in this case occurrences of {
or }
) in each line of a .tex file.
I know that the -o
flag returns only the match, but it returns each match on a new line, even combined with the -n
flag. I don't know of anything I could pipe this through to count the repeats. The -c
flag only returns the total number of matches in the entire file – maybe I could pipe one line at a time to grep?
Best Answer
The output will be something like:
Meaning 3 occurrences in the first line and 1 in the second.
Taken from https://stackoverflow.com/a/15366097/3378354 .