как напечатать количество совпавших / несовпадающих шаблонов и распечатать несколько шаблонов, разделенных строкой.
Пример ввода ( 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
Желаемый результат:
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
==========================================
то, что я пробовал до сих пор:
egrep -o ' 8888 | 3333 | 5555 'test.log | сортировать | uniq -c
output:
4 3333
2 8888
но он не печатает 0 5555
, чтобы указать нулевое вхождение пяти в файле
test.log
желаемый результат:
4 3333
2 8888
0 5555
egrep '8888 | 3333' test.log | sort -V
этот вывод сортировки в алфавитном порядке, а не в соответствии с ожидаемым выводом, как показано ниже:
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
==========================================