我正在执行我的jar文件,它将在shell中创建日志。我的要求是直接从外壳中搜索关键字,而无需创建日志文件。使用此代码
`E:\Innoviti\BankInterfaceAumation>java -jar BankInterfaceAumation.jar 1`
Here is the logs
这是我执行jar时创建的日志
` 3:000000:000000 PASSED4:null:000000001600 FAILED
39:00:00 PASSED------------------------Response Conditions Passed----------------------------
AFter Sale terminal is null
2018-09-06 13:23:23 INFO UniPayTerminalDataFetcherImpl:33 - Fetching unipay terminal with id
Cached terminal or after sale terminal is null/could not be fetched cached terminal is nullAfter sale txn bank terminal null
base transaction is null/could not be fetched
Executing unipay terminal assertions ********************************************
Test Scenario total_txn_amt null SAME null Passed
Comapring property key_exchanged_on value expression SAME
Comparing Simple Exrepssion property SAME
Test Scenario key_exchanged_on null SAME null Passed
Comapring property utid_state value expression 00
Test Scenario utid_state null 00 Failed
Comapring property key_exchanged value expression SAME
L00005022018090613231871319216803136失败`
关键字= Failed
答案 0 :(得分:0)
您可以将日志“管道”到:
grep -o 'Failed' | wc -l
这将计算“失败”的发生率。如果您需要搜索不区分大小写的命令,则grep
命令将变为grep -io
您的命令将变为:
E:\Innoviti\BankInterfaceAumation>java -jar BankInterfaceAumation.jar 1 | grep -o 'Failed' | wc -l
如果想要执行示例,可以尝试:
echo -e 'first line\nfailed Failed\nanother line with failed\nlast line' | grep -io 'failed' | wc -l
此命令的说明可以在这里找到:https://explainshell.com/explain?cmd=echo+-e+%27Some+Failed+text%27+%7C+grep+-o+%27Failed%27+%7C+wc+-l