有command可以加總文字檔內的數字嗎? - Linux

Table of Contents



例如有個ASCII file如下

1.4
3.14
5
......

有沒有command可以直接算出加總等於9.54的?

因為sort可以用 -n 去排大小
所以想知道有沒有這種命令

感謝!

--

你不知道你身上背負著多少責任…對吧?
 ̄ ̄ ̄

--

All Comments

Sierra Rose avatarSierra Rose2010-11-05
expr可以做四則運算 但要自己寫script去讀每一行
Michael avatarMichael2010-11-09
所以必須用shell script嗎?
Daniel avatarDaniel2010-11-12
cat file|awk 'BEGIN{sum=0;} {sum+=$0;} END{print sum;}'
Kumar avatarKumar2010-11-15
wow!! 感謝樓上!!!