什麼是算最有效的方法,措施(計算)兩個時間戳從日誌文件之間之間的時間跨度來衡量的時間跨度最好的方法是什麼? 我知道Excel/Numbers/Refine中的愚蠢解決方案,但我正在尋找一個聰明的awk-oneliner。請告訴我兩個時間戳
示例: 的自動門系統的電梯n個樓層操作。
電梯打開門: Start Move to Work_position
End Move to Work_position
Start Move to Home_Position End Move to Home_Position
Elevator_021 logger: 2017-02-13 13:11:33.735 [MONITORING] CYL_A1; Floor_12 Door ;Start Move to Work_position
Elevator_021 logger: 2017-02-13 13:11:34.800 [MONITORING] CYL_A1; Floor_12 Door ;End Move to Work_position
Elevator_021 logger: 2017-02-13 13:26:12.893 [MONITORING] CYL_A1; Floor_12 Door ;Start Move to Home_Position
Elevator_021 logger: 2017-02-13 13:26:13.898 [MONITORING] CYL_A1; Floor_12 Door ;End Move to Home_Position
Elevator_021 logger: 2017-02-13 14:51:03.211 [MONITORING] CYL_A1; Floor_12 Door ;Start Move to Work_position
Elevator_021 logger: 2017-02-13 14:51:04.276 [MONITORING] CYL_A1; Floor_12 Door ;End Move to Work_position
我盼到像這樣的輸出:
Elevator_021 logger: 2017-02-13 13:11:33.735 [MONITORING] CYL_A1; Floor_12 Door ;Start Move to Work_position
Elevator_021 logger: 2017-02-13 13:11:34.800 [MONITORING] CYL_A1; Floor_12 Door ;End Move to Work_position
to Work 1065 ms
Elevator_021 logger: 2017-02-13 13:26:12.893 [MONITORING] CYL_A1; Floor_12 Door ;Start Move to Home_Position
Elevator_021 logger: 2017-02-13 13:26:13.898 [MONITORING] CYL_A1; Floor_12 Door ;End Move to Home_Position
to Home 1005 ms
Elevator_021 logger: 2017-02-13 14:51:03.211 [MONITORING] CYL_A1; Floor_12 Door ;Start Move to Work_position
Elevator_021 logger: 2017-02-13 14:51:04.276 [MONITORING] CYL_A1; Floor_12 Door ;End Move to Work_position
to Work 3976 ms
thx! 但是,不! \t AWK:在功能DTIME上下文源極線2語法錯誤爲x =匹配($ 0,/([0-9] {4} - [0-9] {2} - [0-9] {2} \ [0-9:] +)(\。\t [0-9] +)。*([0-9] {4} - [0-9] {2} - [0-9] { 2} \ s [0-9:] +)(\。[0-9] +)。*(to >>> \ w +)_ /,<<< awk:source line 2 \t在功能DTIME AWK:在源線2的Funktion之聲 –
非法聲明這將是從1個襯墊在POSIX awk的,因爲它沒有時間的功能遠你可以調查使用'date'的時間戳轉換或使用Perl或。安裝GAWK – dawg
它的工作原理。 - 切換到另一個OS-X機 但僅與相關線的「預分組」 - 需要相關對之間的一個空行 –