对某列(行)数字求和

[root@small-master ~]# kubectl get po -A -o wide |grep Running |awk '{print $5}'  
0
0
0
0
0
1
2
0
1
1
1
2
1
0
1
2
[root@small-master ~]# kubectl get po -A -o wide |grep Running |awk '{print $5}'  | awk '{sum+=$1}END{print sum}'
12

某行
[root@small-master ~]# echo 1 5 6 3 1 |awk '{ for(i=1;i<=NF;i++) sum+=$i; print sum}'
16
posted @ 2022-11-02 10:13  安生丶  阅读(19)  评论(0编辑  收藏  举报