![Linux 获得右侧元素总和的方法](https://linux22.com/image/152445/Linux%20%E8%8E%B7%E5%BE%97%E5%8F%B3%E4%BE%A7%E5%85%83%E7%B4%A0%E6%80%BB%E5%92%8C%E7%9A%84%E6%96%B9%E6%B3%95.png)
答案1
像这样的事情可以帮助:
awk 'BEGIN {sum=0} {sum+=$2} END {print "Total "sum}' input_file.txt
答案2
由 python 完成,效果很好
#!/usr/bin/python
sum=0
m=open('filename','r')
m.readline()
k=[]
for i in m:
k.append(i.strip().split('\t')[-1].strip())
for j in k:
y=int(j)
sum=sum+y
print "Total is {0}".format(sum)
输出
python script.py
Total is 236