Guest User

Untitled

a guest
Apr 23rd, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.28 KB | None | 0 0
  1. # takes a file with a column of numbers and sums them
  2.  
  3. function summr(){
  4. sum=0
  5. for i in $(cat $1)
  6. do
  7. sum=$(echo "$sum + $i" | bc)
  8. done
  9.  
  10. echo $sum
  11. }
  12.  
  13.  
  14. # Example
  15. npowell@malaise:~$ cat summe.txt
  16. 31.70
  17. 65.94
  18. 122.40
  19. 100.00
  20. 66.00
  21. npowell@malaise:~$ summr summe.txt
  22. 386.04
Add Comment
Please, Sign In to add comment