答案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