我正在嘗試逐行讀取一個特定字符串及其值的日誌文件。解析unix日誌文件
比如我有一個日誌文件,如下圖所示:
####<Sep 26, 2013 12:05:22 AM MDT> <Error> <comApp> <ap001> <Server12> <[ACTIVE] ExecuteThread: '55' for queue: 'weblogic.kernel.Default (self-tuning)'> <<anonymous>> <> <> <1380175522589> <000000> <<ERROR>Exception ID: 971 - Rate with ResParameters-> MAT: SJC GHT: FJC PUD: Fri Sep 27 09:00:00 MDT 2013>
####<Sep 26, 2013 12:05:22 AM MDT> <Error> <comApp> <ap001> <Server12> <[ACTIVE] ExecuteThread: '55' for queue: 'weblogic.kernel.Default (self-tuning)'> <<anonymous>> <> <> <1380175522593> <000000> <<ERROR>Exception ID: 971 - Rate with ResParameters-> MAT: SJC GHT: FJC PUD: Fri Sep 27 09:00:00 MDT 2013>
####<Sep 26, 2013 12:05:22 AM MDT> <> <Error> <comApp> <ap001> <Server12> <[ACTIVE] ExecuteThread: '55' for queue: 'weblogic.kernel.Default (self-tuning)'> <<anonymous>> <> <> <1380175522597> <000000> <<ERROR>Exception ID: 971 - Rate with ResParameters-> MAT: SJC GHT: FJC PUD: Fri Sep 27 09:00:00 MDT 2013>
我需要閱讀從定義字符串值MAT GHT:,:,PUD:
我試圖讓輸出:
SJC , FJC, Fri Sep 27 09:00:00 MDT 2013
DJA , SJC, Fri Sep 27 09:00:00 MDT 2013
FJC , KJC, Fri Sep 27 09:00:00 MDT 2013
JJC , SJC, Fri Sep 27 09:00:00 MDT 2013
我覺得'sed'會成爲解決這個問題的好工具。你可以很容易地找到教程,並在這裏問問如果你有任何問題 –