Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # takes a file with a column of numbers and sums them
- function summr(){
- sum=0
- for i in $(cat $1)
- do
- sum=$(echo "$sum + $i" | bc)
- done
- echo $sum
- }
- # Example
- npowell@malaise:~$ cat summe.txt
- 31.70
- 65.94
- 122.40
- 100.00
- 66.00
- npowell@malaise:~$ summr summe.txt
- 386.04
Add Comment
Please, Sign In to add comment