日期:2014-05-16 浏览次数:20742 次
J:\Project\Perl>perl -nle "@ds = m|^:([^[]+)[^:]+:\(([^)]+)[^:]+:(.*?)ms$|; print qq(@ds);" l5.txt 2012/8/4 1:53:9 GetAppComments 5.329000 2012/8/4 1:53:9 GetAppComments 4.962000 2012/8/4 1:53:10 GetAppComments 5.840000 2012/8/4 1:53:11 GetAppComments 5.441000 2012/8/4 1:53:11 GetAppComments 5.031000 2012/8/4 1:53:17 GetAppComments 5.354000 2012/8/4 1:53:25 GetAppComments 6.416000 2012/8/4 1:53:26 GetAppComments 3.321000 2012/8/4 1:53:37 GetAppComments 5.821000 2012/8/4 1:53:38 GetAppComments 12.046000 J:\Project\Perl>
------解决方案--------------------
[liangdong@bb-browser-test00.vm.baidu.com sh_project]$ ./main.sh 2012/8/4 GetAppComments 5.329000 2012/8/4 GetAppComments 4.962000 2012/8/4 GetAppComments 5.840000 2012/8/4 GetAppComments 5.441000 2012/8/4 GetAppComments 5.031000 2012/8/4 GetAppComments 5.354000 2012/8/4 GetAppComments 6.416000 2012/8/4 GetAppComments 3.321000 2012/8/4 GetAppComments 5.821000 2012/8/4 GetAppComments 12.046000 [liangdong@bb-browser-test00.vm.baidu.com sh_project]$ cat main.sh #!/bin/bash while read line;do line=`echo $line | tr "()" " " | cut -c 2- | awk '{gsub("time:|ms", "", $5);print $1" "$3" "$5}'` echo $line done < a.txt