- 论坛徽章:
- 0
|
非常感谢楼上的兄弟
但是你的脚本在我的Linux bash环境运行的结果不太对呢?不知道兄弟是在什么shell环境下跑出来的。
[root@dg1 ~]# cat 2
CPU read messag log read
14.76 31.46 17.29 8.6 5.73
14.37 38.41 14.34 11.53 4.13
23.82 34.92 11.95 8.39 0
17.25 45.81 9.47 6.75 4.68
21.59 42.5 9.87 6.82 0
19.56 36.36 11.56 7.93 0
[root@dg1 ~]#
[root@dg1 ~]# awk '{for(i=1;i<=NF;i++)a[i,NR]=$i}END{for(i=1;i<=NF;i++){for(j=1;j<=NR;j++)printf a[i,j]" ";print ""}}' file|awk '{b=$2;for(i=2;i<=NF;i++){b=$i>b?bi}min=b;for(i=2;i<=NF;i++){b=$i>b?$i:b}max=b;x=0;for(i=2;i<=NF;i++){x+=$i}avg=x/NF;print $1"\t""最小",min "\t" "最大值:" ,max "\t" "平均值:",avg}' 2
CPU 最小值: log 最大值: read 平均值: 0
14.76 最小值: 5.73 最大值: 31.46 平均值: 12.616
14.37 最小值: 4.13 最大值: 38.41 平均值: 13.682
23.82 最小值: 0 最大值: 34.92 平均值: 11.052
17.25 最小值: 4.68 最大值: 45.81 平均值: 13.342
21.59 最小值: 0 最大值: 42.5 平均值: 11.838
19.56 最小值: 0 最大值: 36.36 平均值: 11.17
awk: cmd. line:1: fatal: cannot open file `file' for reading (No such file or directory) |
|