I'm trying to get some trivial statistics on some debug output.
Each debug line is of the form
(class name)(delimiter 1)(object ID)(delimiter 2)(method name)(delimiter 3)(log message)
I want to get a count of how many lines are coming from which methods.
Essentially, if each line can be reduced to
(class name)(delimiter)(method name), I want to know how many occurences of each of those reductions appear in the log file.
What command can I run in Bash to do the counting?
(I'm doing this on macOS with macports replacing most of the default BSD-style tools with GNU tools.)
I can extract the class name with
grep -o -E "^.*(delimiter 1), or extract the method name with
grep -o -E "(delimiter 2).*(delimiter 3)", or highlight both with
grep --color=always -E "^.*(delimiter 1)|(delimiter 2).*(delimiter 3)". I got stuck looking for a way to get
grep to output just the two matches which could then be run through
| uniq -c to do the counting.
Is there a way to get
grep to print both matches for each line rather than just one match or the entire line?