
フォルダーに次の形式のデータ ファイルをダンプするバッチ テストがいくつかあります。各テストは 1 つのファイルをダンプし、ファイル名は一般的なシリアル番号です。テスト名を使用して、失敗したすべてのログ ファイル名のリストを生成したいと思います。
xargs は使用できますが、Testname を印刷できません。次のスクリプトはすべてのログ ファイルをダンプします。これは実行可能ですが、より優れた解決策が必要です。
grep 'Fail\|テスト名' *.log
サンプルファイル test_0123.log
[other log of 20MB]
* Result : Pass/Fail
* Testname : test_example_rsa_key_gen
[other log and trailer]
答え1
perl -0777ne 'if ( /Result : Fail/ and /Testname : (\S+)/ ) { print "filename: $ARGV; testname: $1" }' *.log