i want to calculate:
- the total points (sum)
- the today points (sum)
- the total points (average)
- the today points (average)
i have no idea with bash scripting other than i need to start with: #!/bin/bash
here’s a sample of my file
#file 14516 - 2011-01-26 19:01:00 EDT#
user: xxxxxxxx@email.com / id(11451611)
lastlogin: 1295896515
total_points: 11.76 / today: 5.21
gameid: 51
user: xxxxxxxx@email.com / id(11837327)
lastlogin: 1293893041
total_points: 416.1 / today: 98.1
gameid: 49
user: xxxxxxxx@email.com / id(11451611)
lastlogin: 1294917135
total_points: 1.76 / today: 0.21
gameid: 51
You can use this:
Then save to a file like:
script.shChange the permission to executable:
chmod +x script.shThen run it:
./script.sh sample.txtThis will output:
Note:
$1will the the input file.Here’s more help about the bc command, grep, awk