gpt4 book ai didi

linux - 从管道输入中 grep 多个搜索模式并递增地报告单个计数

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:00:01 25 4
gpt4 key购买 nike

有一些输出从具有模式“通过”、“失败”、“崩溃”的测试中涌现出来,我希望能够在屏幕上看到随着测试的计数进展而增加的输出

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}'

关于linux - 从管道输入中 grep 多个搜索模式并递增地报告单个计数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7852605/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com