0
2つの正規表現の間にファイルのセクションを印刷しようとしています。最初の式はパターン1、Error:
またはパターン2 FAILED
のいずれかであり、最後の式は固定パターン(----------
)です。ファイルのセクションの複数のパターンマッチング
例:
cat FILE* | sed -n '/Error/,/------/p' >> ${TEMP}/err.tmp
cat FILE* | sed -n '/FAILED/,/------/p' >> ${TEMP}/err.tmp
しかし、私の出力は、テキストが表示される順序ではありません。
Line 01
10-10-16 22:23:34 Error: Failed to update discount row [Customer ABC|£-336.95]
10-10-16 22:23:34 Error processing file information, Block 27.
----------------------------------------------------------------------
Line 05
Line 06
Line 07
10-10-16 22:26:52 Error: Failed to update discount row [Customer DEF|£-0.66]
10-10-16 22:26:52 Error processing file information, Block 37.
----------------------------------------------------------------------
Line 11
Line 12
Line 13
20161010 22:28:25 File 6 FAILED... FILE11.txt
----------------------------------------------------------------------
Line 16
Line 17
Line 18
10-10-16 22:31:30 Error: Failed to update discount row [Customer JKL|£-155.88]
10-10-16 22:31:30 Error processing file information, Block 3.
----------------------------------------------------------------------
Line 22
Line 23
Line 24
10-10-16 22:33:04 Error: Failed to update discount row [Customer MNO|£-12.65]
10-10-16 22:33:04 Error processing file information, Block 9.
Line 27
Line 28
Line 29
20161010 22:35:41 File 7 FAILED... FILE12.txt
----------------------------------------------------------------------
The output I'm looking for is below
10-10-16 22:23:34 Error: Failed to update discount row [Customer ABC|£-336.95]
10-10-16 22:23:34 Error processing file information, Block 27.
----------------------------------------------------------------------
10-10-16 22:26:52 Error: Failed to update discount row [Customer DEF|£-0.66]
10-10-16 22:26:52 Error processing file information, Block 37.
20161010 22:28:25 File 6 FAILED... FILE11.txt
----------------------------------------------------------------------
10-10-16 22:31:30 Error: Failed to update discount row [Customer JKL|£-155.88]
10-10-16 22:31:30 Error processing file information, Block 3.
----------------------------------------------------------------------
10-10-16 22:33:04 Error: Failed to update discount row [Customer MNO|£-12.65]
10-10-16 22:33:04 Error processing file information, Block 9.
20161010 22:35:41 File 7 FAILED... FILE12.txt
----------------------------------------------------------------------
私は何を得ることができたことは、このコマンドを使用して、1つまたは他のですファイル内:
10-10-16 22:23:34 Error: Failed to update discount row [Customer ABC|£-336.95]
10-10-16 22:23:34 Error processing file information, Block 27.
----------------------------------------------------------------------
10-10-16 22:26:52 Error: Failed to update discount row [Customer DEF|£-0.66]
10-10-16 22:26:52 Error processing file information, Block 37.
----------------------------------------------------------------------
10-10-16 22:31:30 Error: Failed to update discount row [Customer JKL|£-155.88]
10-10-16 22:31:30 Error processing file information, Block 3.
----------------------------------------------------------------------
10-10-16 22:33:04 Error: Failed to update discount row [Customer MNO|£-12.65]
10-10-16 22:33:04 Error processing file information, Block 9.
----------------------------------------------------------------------
20161010 22:28:25 File 6 FAILED... FILE11.txt
----------------------------------------------------------------------
20161010 22:35:41 File 7 FAILED... FILE12.txt
----------------------------------------------------------------------
私は解決策をオンラインで検索しています1つを見つけることができませんでした。
パーフェクト。まさに私が探していたもの。クール。ありがとうございました。 –