I have coded an analyzer which analyzes a file, and returns different results: GOOD
, BAD
, Unexpected exception :
which is followed by different exceptions... My makefile
runs this analyzer on a set of files one by one, and puts the whole result in one file output.txt
. So the output.txt
looks like as follows:
file "f1.txt"
...
GOOD
file "f2.txt"
...
Unexpected exception : exception1
...
Unexpected exception : exception2
...
Now I would like to write a shell script summary
which summarizes output.txt
, especially lists what exceptions are raised and their number of occurrence. It should like like:
exception1 : 9
exception2 : 15
...
The order of the exceptions has no importance, (well, if it is sorted by the number of the occurrence, it would be better)...
I know grep "Unexpected exception" output.txt | wc -l
will return the number of occurrence of all the exceptions, but I do need to know the occurrence for each exception raised...
Does anyone know how to write this summary
script?