awk指定列求和简单示例
作者:互联网
# test.txt
20000000000069|950615951|2019-04|3.70
20000000000069|950615951|2019-05|1.30
20000000000069|950615951|2019-06|1.30
20000000000069|950615951|2019-08|1.50
20000000000069|950615951|2019-09|1.40
20000000000069|950615951|2019-10|1.60
20000000000069|950615951|2019-11|3.55
20000000000069|950615951|2019-12|1.00
20000000000069|950615951|2020-01|1.00
20000000000069|950615951|2020-02|1.00
# 第4列求和
# 方式一
cat test.txt |awk -F'|' '{sum+=$4} END {print "Sum = ", sum}'
# 方式二
sed 's/|/ /g' test.txt |awk '{sum+=$4} END {print "Sum = ", sum}'
标签:1.00,示例,求和,sum,20000000000069,2019,awk,txt,950615951 来源: https://blog.csdn.net/sosemseo/article/details/115556209