1. 对一列数据求和
awk 'BEGIN {sum=0} {sum+=$1} END {print sum}' data.txt
awk -F ',' 'BEGIN {sum=0 ;count=0} {sum +=$5; count++;} END {print "sum="sum" count="count " avg="sum/count}'
find * -type f | awk '{print "mv "$1" "$1".new"}'
4. 当一列匹配某一字符串时打印
$ awk '$4 ~/Technology/' employee.txt200 Jason Developer Technology $5,500300 Sanjay Sysadmin Technology $7,000500 Randy DBA Technology $6,000
5. printf
awk '{ printf "%-10s %s\n", $1, $2 }' BBS-list