how to print the count of matched /unmatched patterns and print multiple patterns separated by line.
Input example (test.log
):
This 23 line has eight 8888
This 11 line has three 3333
need 12 to separate eight and three 3333
eight 32 is greater than three 8888
three 13 is less than eight 3333
three 14 is printed more than eight 3333
Desired output :
8888:4
3333:2
5555:0
This 11 line has three 3333
need 12 to separate eight and three 3333
three 13 is less than eight 3333
three 14 is printed more than eight 3333
============================================
This 23 line has eight 8888
eight 32 is greater than three 8888
==========================================
what i have tried so far :
- to get the number of lines:
egrep -o '8888|3333|5555' test.log | sort| uniq -c
output:
4 3333
2 8888
but it's not printing 0 5555
to indicate zero occurrence of five in file
test.log
desired output:
4 3333
2 8888
0 5555
egrep '8888|3333' test.log | sort -V
this sort output in alphabetic order and not according to the output i expect as shown below :
This 11 line has three 3333
need 12 to separate eight and three 3333
three 13 is less than eight 3333
three 14 is printed more than eight 3333
============================================
This 23 line has eight 8888
eight 32 is greater than three 8888
==========================================