我有一个文件,其数据格式为:
7/26/2018 10:01:52.084 MULTITHREAD APP It goes to preserve the context of the destination window LAESVEES03ES0301C when setting the origin data DATA_ENTRY
"n lines"
7/26/2018 12:15:51.512 AWT-EventQueue-0 **Protecting** graphical interface
7/26/2018 12:17:00.121 MULTITHREAD APP It goes to preserve the context of the destination window LARTVERT31RT3111C when setting the origin data DATA_ENTRY
7/26/2018 12:52:48.681 MULTITHREAD APP **Unprotecting** graphic interface
"n lines"
7/26/2018 14:00:51.512 AWT-EventQueue-0 **Protecting** graphical interface
7/26/2018 14:35:35.230 MULTITHREAD APP It goes to preserve the context of the destination window LAPEVEBIOMBIOM03C when setting the origin data DATA_ENTRY
7/26/2018 14:52:48.681 MULTITHREAD APP **Unprotecting** graphic interface
"n lines"
7/26/2018 15:00:51.512 AWT-EventQueue-0 **Protecting** graphical interface
7/26/2018 15:11:19.100 MULTITHREAD APP It goes to preserve the context of the destination window LAPEVEPE27PE2701C when setting the origin data DATA_ENTRY
7/26/2018 15:22:48.681 MULTITHREAD APP **Unprotecting** graphic interface
"n lines"
7/26/2018 15:00:51.512 AWT-EventQueue-0 **Protecting** graphical interface
7/26/2018 15:11:19.100 MULTITHREAD APP It goes to preserve the context of the destination window LARTVEIT29IT2901C when setting the origin data DATA_ENTRY
7/26/2018 15:22:48.681 MULTITHREAD APP **Unprotecting** graphic interface
"n lines"
7/26/2018 15:30:53.512 AWT-EventQueue-0 Protecting graphical interface
7/26/2018 15:41:19.100 MULTITHREAD APP It goes to preserve the context of the destination window LAPEVEPE27PE2701C when setting the origin data DATA_ENTRY
7/26/2018 15:49:48.681 MULTITHREAD APP Unprotecting graphic interface
"n lines"
7/26/2018 16:55:35.000 MULTITHREAD APP It goes to preserve the context of the destination window LAPEVEBIOMBIOM03C when setting the origin data DATA_ENTRY
"n lines"
7/26/2018 16:23:00.000 MULTITHREAD APP It goes to preserve the context of the destination window LARTVERT31RT3111C when setting the origin data DATA_ENTRY
"n lines"
7/26/2018 16:31:31.000 MULTITHREAD APP It goes to preserve the context of the destination window LAESVEES03ES0301C when setting the origin data DATA_ENTRY
"n lines"
我想以这种方式退出: 日期,小时开始,小时结束,Windows_APP
例如:
7/26/2018,12:15:51.512,12:52:48.681,LARTVERT31RT3111C
7/26/2018,14:00:51.512,14:52:48.681,LAPEVEBIOMBIOM03C
7/26/2018,15:00:51.512,15:22:48.681,LAPEVEPE27PE2701C
7/26/2018,15:00:51.512,15:22:48.681,LARTVEIT29IT2901C
我在这里停留是因为他们开始重复LAPEVEPE27PE2701C,LAPEVEBIOMBIOM03C,LARTVERT31RT3111C和 LAESVEES03ES0301C (从这里开始)
具有此数据的文件重量约为3.5Mb。而且有很多行
有人可以帮助我如何使用awk或类似的工具(perl或bash)
答案 0 :(得分:-1)
检查此Perl解决方案:
$ head win_app.dat
7/26/2018 12:15:51.512 AWT-EventQueue-0 **Protecting** graphical interface
7/26/2018 12:17:00.121 MULTITHREAD APP It goes to preserve the context of the destination window LARTVERT31RT3111C when setting the origin data DATA_ENTRY
7/26/2018 12:52:48.681 MULTITHREAD NACAR **Unprotecting** graphic interface
"n lines"
7/26/2018 14:00:51.512 AWT-EventQueue-0 **Protecting** graphical interface
7/26/2018 14:35:35.230 MULTITHREAD APP It goes to preserve the context of the destination window LAPEVEBIOMBIOM03C when setting the origin data DATA_ENTRY
7/26/2018 14:52:48.681 MULTITHREAD NACAR **Unprotecting** graphic interface
"n lines"
7/26/2018 15:00:51.512 AWT-EventQueue-0 **Protecting** graphical interface
7/26/2018 15:11:19.100 MULTITHREAD APP It goes to preserve the context of the destination window LAPEVEPE27PE2701C when setting the origin data DATA_ENTRY
$ perl -lane ' { $x=sprintf("%s,%s",$F[0],$F[1]) if /AWT-EventQueue/ ; $y=sprintf("%s",$F[-7]) if /MULTITHREAD APP/; $z=sprintf("%s",$F[1]) if /MULTITHREAD NACAR/ ; print "$x,$z,$y" if /n lines/ } ' win_app.dat
7/26/2018,12:15:51.512,12:52:48.681,LARTVERT31RT3111C
7/26/2018,14:00:51.512,14:52:48.681,LAPEVEBIOMBIOM03C
7/26/2018,15:00:51.512,15:22:48.681,LAPEVEPE27PE2701C
7/26/2018,15:00:51.512,15:22:48.681,LARTVEIT29IT2901C
7/26/2018,15:30:53.512,15:49:48.681,LAPEVEPE27PE2701C
7/26/2018,15:30:53.512,15:49:48.681,LAPEVEBIOMBIOM03C
7/26/2018,15:30:53.512,15:49:48.681,LARTVERT31RT3111C
7/26/2018,15:30:53.512,15:49:48.681,LAESVEES03ES0301C
$