# 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}'