Guest User

Untitled

a guest
Aug 5th, 2018
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. calculate data in linux
  2. #file 14516 - 2011-01-26 19:01:00 EDT#
  3. user: xxxxxxxx@email.com / id(11451611)
  4. lastlogin: 1295896515
  5. total_points: 11.76 / today: 5.21
  6. gameid: 51
  7.  
  8. user: xxxxxxxx@email.com / id(11837327)
  9. lastlogin: 1293893041
  10. total_points: 416.1 / today: 98.1
  11. gameid: 49
  12.  
  13. user: xxxxxxxx@email.com / id(11451611)
  14. lastlogin: 1294917135
  15. total_points: 1.76 / today: 0.21
  16. gameid: 51
  17.  
  18. #!/bin/bash
  19.  
  20. if [ ! -f $1 ]; then
  21. echo "File $1 not found"
  22. exit 1
  23. fi
  24.  
  25. number=$(grep total_points $1 | wc -l )
  26. sumTotal=$(grep total_points $1 | awk '{sum+=$2} END { print sum }')
  27. sumToday=$(grep total_points $1 | awk '{sum+=$5} END { print sum }')
  28.  
  29. echo "Total SUM: $sumTotal"
  30. echo -n "Total AVG: "
  31. echo "scale=5;$sumTotal/$number" | bc
  32.  
  33. echo "Today SUM: $sumToday"
  34. echo -n "Today AVG: "
  35. echo "scale=5;$sumToday/$number" | bc
  36.  
  37. Total Record: 3
  38. Total SUM: 429.62
  39. Total AVG: 143.20666
  40. Today SUM: 103.52
  41. Today AVG: 34.50666
Add Comment
Please, Sign In to add comment