有一些输出是从模式为“passed”、“failed”、“crashed”的测试中发出的,我希望能够在屏幕上看到增量输出,因为测试正在进行计数

run_tests | <grep or some command that does counting>
PASSED 1 FAILED 0 CRASHED 0
.. after running 25 tests
PASSED 20 FAILED 5 CRASHED 0

最佳答案

awk 'BEGIN{passed = 0; failed = 0; crashed=0}
/PASSED/{passed++} /FAILED/{failed++} /CRASHED/{crashed++}
{print "PASSED " passed " FAILED " failed " CRASHED " crashed}'

08-04 21:47