2017-03-27 103 views
0

我有這樣的事情:在一個命令多個輸入

ERROR_CODE = 1; NUM = 5;

Error_code = 2; NUM = 7;

Error_code = 3; NUM = 9;

Error_code = 1; NUM = 2;

Error_code = 2; NUM = 5;

。 。 。

和錯誤代碼很多(約100) 假裝叫performance.log每次

如何使用一個命令,但文件中的錯誤代碼是不同的 像:

grep -i "error_code=$x;" performance.log | awk -F";" '{print $2}' > $x_error_code.txt 

所以每次變量x是從錯誤代碼 定義的新值並且當錯誤代碼完成時,腳本將完成

+0

你已經試過了什麼?如果你問一個具體的問題而不是一般的建議,那會更好。 – Brody

+0

你期待什麼結果? – RomanPerekhrest

+0

@RomanPerekhrest文件中的每個錯誤代碼 –

回答

0

要將輸入文件拆分爲單個文件ch 錯誤代碼

awk -F";" '{fn=substr($1, index($1,"=")+1); print $2 > fn"_error_code.txt";}' performance.log 
相關問題