Shell脚本统计问题
文件 file1
姓名 金额
john 235
smith 457
lily 785
john 561
用shell脚本统计人员消费的次数 和 金额
初次接触,望高手不吝赐教
姓名 金额
john 235
smith 457
lily 785
john 561
用shell脚本统计人员消费的次数 和 金额
初次接触,望高手不吝赐教
作者: suihuan111 发布时间: 2011-03-06
自己顶 在线等
作者: suihuan111 发布时间: 2011-03-06
awk '{a[$1]+=$2}END{for(i in a)print i,a[i]}' file1
作者: lgxwqq111 发布时间: 2011-03-06
shell$ cat text
姓名 金额
john 235
smith 457
lily 785
john 561
shell$ awk '{sum+=$2};END {print "总消费次数为:" NR-1 ORS "总金额为:" sum}' text
总消费次数为:4
总金额为:2038
初学shell 多多指教
姓名 金额
john 235
smith 457
lily 785
john 561
shell$ awk '{sum+=$2};END {print "总消费次数为:" NR-1 ORS "总金额为:" sum}' text
总消费次数为:4
总金额为:2038
初学shell 多多指教
作者: PfanAya 发布时间: 2011-03-06