0
我有两种以下格式的长日志。日志1:使用bash合并来自两个日志文件的列
@ autoscale onread none
@ with g0
@ g0 on
@ title "projection on eigenvectors (nm)"
@ xaxis label "Time (ps)"
@ world xmin 6.94688e-310
@ world xmax 0.0479958
@ world ymin 1.84622
@ world ymax 4.02719
@ view xmin 0.15
@ view xmax 0.85
@ view ymin 0.15
@ view ymax 0.85
@ yaxis label "vec 1"
@ xaxis tick major 0.01
@ xaxis tick minor 0.005
@ xaxis ticklabel start type spec
@ xaxis ticklabel start 1.85
@ yaxis tick major 1
@ yaxis tick minor 0.5
@ yaxis ticklabel start type spec
@ yaxis ticklabel start 2
0.0000 2.23088
0.0980 2.19816
0.1137 2.26237
0.0934 2.28405
0.0926 2.26499
.................
0.0911 2.20825
0.0873 2.32075
日志2
@ autoscale onread none
@ with g0
@ g0 on
@ title "projection on eigenvectors (nm)"
@ xaxis label "Time (ps)"
@ world xmin 6.94067e-310
@ world xmax 0.0889754
@ world ymin -2.16935
@ world ymax 1.86708
@ view xmin 0.15
@ view xmax 0.85
@ view ymin 0.15
@ view ymax 0.85
@ yaxis label "vec 2"
@ xaxis tick major 0.02
@ xaxis tick minor 0.01
@ xaxis ticklabel start type spec
@ xaxis ticklabel start -2.16
@ yaxis tick major 2
@ yaxis tick minor 1
@ yaxis ticklabel start type spec
@ yaxis ticklabel start -2
@ zeroxaxis bar on
@ zeroxaxis bar linestyle 3
0.0000 1.08899
0.1161 0.94107
0.1056 0.54611
0.1033 0.73843
0.0987 1.06740
.................
0.1081 0.90706
从每对中的给定的日志我需要从部分采取仅将第二列的其中出现的数字的两列(它可以在发生不同日志中的不同字符串编号,但其结构相同,并且具有2列数字的字符串数量也相同)。从而产生一个新的日志在老格式(见下面的例子为两个给定的原木):
2.23088 1.08899
2.19816 0.94107
2.26237 0.54611
2.28405 0.73843
2.26499 1.06740
我曾经通过
paste log1.txt log2.txt | awk '/^[^;&@#]/{print $2, $4}' > result.log
做,但有时它采取错误的字符串(不但是从第二个日志中的字符串开头的标头开始,所以生成的日志包含错误。像
2.23088 zeroxaxis
2.19816 zeroxaxis
2.26237 2.15530
2.28405 1.93111
2.26499 1.45075
2.51312 1.54586
2.40316 1.50173
2.20825 1.92454
2.32075 1.89937
2.37953 1.38487
2.30873 1.44963
2.06744 1.40712
我将因此感谢您的建议如何解决它!
格列布
这似乎只能从数字的第一行打印值。 –
哦,是的,现在检查我更新的答案。 – anubhava
@ user3470313:这是否适合你? – anubhava