shell常用指令

1. 批量杀死进程

ps -ef | grep <key_word> | grep -v grep | awk '{print $2}' | xargs kill -9

2. 算术计算

2.1. 计算总和

$ cat count.txt | awk '{sum+=$1} END {print "Sum = ", sum}'

2.2. 计算平均值

$ cat count.txt | awk '{sum+=$1} END {print "Average = ", sum/NR}'
Table of Contents