awk 计算

[root@BJ-DATABASES lastday]# ps -aux| grep nginx|grep -v grep
root 13783 0.0 0.0 56796 1208 ? Ss 11:13 0:00 nginx: master process nginx
deploy 13786 0.0 0.3 61944 6784 ? S 11:13 0:00 nginx: worker process
deploy 13787 0.0 0.3 61944 6784 ? S 11:13 0:00 nginx: worker process
deploy 13788 0.0 0.3 61944 6784 ? S 11:13 0:00 nginx: worker process
deploy 13789 0.0 0.3 61944 6528 ? S 11:13 0:00 nginx: worker process
[root@BJ-DATABASES lastday]# ps -aux| grep nginx|awk '{sum+=$2;num+=$7}'END'{print sum,num}'
132213 0
[root@BJ-DATABASES lastday]# ps -aux| grep nginx|grep -v grep|awk '{all=$5+$6;print all}'
58004
68728
68728
68728
68472

原文地址:https://www.cnblogs.com/liuyoushui/p/12347531.html