我有一个生成的跟踪,想要根据shell命令awk
和sed
进行一些简单的分析。跟踪的格式为:
../filter_on/2016-01-11--22.24.30/ruby/observ/out/observ_jruby_optimalj9_OUT:11/Jan/2016:22:50:03:941 java.lang.invoke.ReceiverBoundHandle MethodHandle(ThreadContext)IRubyObject
../filter_on/2016-01-11--22.24.30/ruby/printff/out/printff_jruby_optimalj9_OUT:11/Jan/2016:22:29:30:585 java.lang.invoke.ReceiverBoundHandle null
../filter_on/2016-01-11--22.24.30/ruby/printff/out/printff_jruby_optimalj9_OUT:11/Jan/2016:22:29:30:586 java.lang.invoke.PermuteHandle null
../filter_on/2016-01-11--22.24.30/ruby/cal/out/cal_jruby_optimalj9_OUT:11/Jan/2016:22:54:17:683 java.lang.invoke.ReceiverBoundHandle null
../filter_on/2016-01-11--22.24.30/ruby/cal/out/cal_jruby_optimalj9_OUT:11/Jan/2016:22:54:17:684 java.lang.invoke.ReceiverBoundHandle null
我的预期输出是表格:
observ ReceiverBoundHandle MethodHandle(ThreadContext)IRubyObject 1
printff PermuteHandle null 1
printff ReceiverBoundHandle null 1
cal ReceiverBoundHandle null 2
最后一列是看到前三列的时间。
答案 0 :(得分:0)
我正在使用awk
,sort
和uniq
。如果你可以忍受这个并且重复的计数器是第一列而不是最后一列,那么这应该做:
cat trace | awk -F "[/ ]+" '{print $5"\t"$10"\t"$11}' | sort | uniq -c
输入文件的输出如下:
2 cal java.lang.invoke.ReceiverBoundHandle null
1 observ java.lang.invoke.ReceiverBoundHandle MethodHandle(ThreadContext)IRubyObject
1 printff java.lang.invoke.PermuteHandle null
1 printff java.lang.invoke.ReceiverBoundHandle null