ps -eo size,pid,user,command --sort -size | awk '{ hr=$1/1024 ; printf("%13.2f Mb ",hr) } { for ( x=4 ; x<=NF ; x++ ) { printf("%s ",$x) } print "" }'| grep nginx| grep -v grep|awk '{sum+=$1}END{ print"average="sum/NR}' 计算平均值
ps -eo size,pid,user,command --sort -size | awk '{ hr=$1/1024 ; printf("%13.2f Mb ",hr) } { for ( x=4 ; x<=NF ; x++ ) { printf("%s ",$x) } print "" }'| grep nginx| grep -v grep|awk '{sum+=$1}END{ print"sum="sum}' 计算总和
ps -eo size,pid,user,command --sort -size | awk '{ hr=$1/1024 ; printf("%13.2f Mb ",hr) } { for ( x=4 ; x<=NF ; x++ ) { printf("%s ",$x) } print "" }'| grep nginx| grep -v grep|awk '{sum+=$1}END{ print"sum="sum;print"average="sum/NR}' 输出总和和平均值 进程自己替换