我有特别令人讨厌的shell编程,在shell脚本中没有多少经验。我有以下文本文件。我需要做的是计算子集1的平均值Y(m)和子集2的平均值Y(m)之间的差值。可以有两个以上的子集,但它足以计算子集之间的差异1和子集2.Shell脚本来计算两个不同子集的列之间的平均值
我尝试了各种awk命令,但似乎我的大脑被太多的障碍炸了。 Arghhh!
MODEL PARAMETERS :
Project : Report
Dataset : xxx
Number of subsets : 2
Total number : 8
Subset number : 1
Subset name : xxx_sub1
Number : 4
NR TYPE X(m) Y(m) Z(m) Volume Pressure CluNo Activ Group
--- --------------------- ------ ------ ----- ------- -------- ----- ----- ------
1 Type text 0.00 -10.40 9.00 2000.0 500.0 0 0 1
2 Type text 0.00 -9.60 9.00 1000.0 500.0 0 1 1
3 Type text 3.00 -10.40 9.00 1200.0 500.0 1 1 1
4 Type text 3.00 -9.60 9.00 800.0 500.0 1 1 1
Subset number : 2
Subset name : xxx_sub2
Number : 4
NR TYPE X(m) Y(m) Z(m) Volume Pressure CluNo Activ Group
--- --------------------- ------ ------ ----- ------- -------- ----- ----- ------
1 Type text 0.00 10.40 15.00 2000.0 500.0 0 0 1
2 Type text 0.00 9.60 15.00 1000.0 500.0 0 1 1
3 Type text 3.00 10.40 15.00 1200.0 500.0 1 1 1
4 Type text 3.00 9.60 15.00 800.0 500.0 1 1 1
Units :
Coordinates : meter
Volume : cubic cm
Pressure : pascal
基本上我需要在第一组Y(M)值的平均值:(-10.4-9.6-10.4-9.6)/ 4 = -10m和平均第二组Y(m)值的哪是(10.4 + 9.6 + 10.4 + 9.6)/ 4 = 10m并计算两个平均值之间的差值为20m。
'我尝试了各种awk命令,但是...'。你能详细说明你尝试了什么吗? – devnull
预期产量是多少? –
除符号外,Y(m)在子集#1和#2上具有相同的值。给出一个例子来计算,我们可以提取它。 – Jotne