Created
March 14, 2016 18:03
-
-
Save jamesattard/aba01ccbc7e50d6551a1 to your computer and use it in GitHub Desktop.
summarise r2d counts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| sum=0 | |
| [ $# -ge 1 -a -f "$1" ] && input="$1" | |
| cat $input | grep -o '[0-9]*' | while IFS= read -r line | |
| do | |
| sum=$((sum + line)) | |
| echo $sum >> /tmp/sum.tmp | |
| done | |
| tail -1 /tmp/sum.tmp | |
| rm /tmp/sum.tmp |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
~/code cat garbage.txt
output from DS1988:
1258
output from DS1989:
1326
output from DS1990:
1184
output from DS1991:
1265
output from DS1992:
1479
output from DS1993:
1345
~/code cat garbage.txt | ./summarise2.sh
7857