File: fetch-stats.sh

package info (click to toggle)
hfst 3.16.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 14,532 kB
  • sloc: cpp: 101,875; sh: 6,717; python: 5,225; yacc: 4,985; lex: 2,900; makefile: 2,017; xml: 6
file content (34 lines) | stat: -rwxr-xr-x 871 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/sh

if [ -f "results" -o -d "results" ]; then
    echo "file/directory 'results' exists"
    exit 1
fi
touch results

if [ -f "foo" -o -d "foo" ]; then
    echo "file/directory 'foo' exists"
    exit 1
fi

for year in 2016;
do
    for month in `seq --equal-width 39 52`;
    do
        url="http://apertium.projectjj.com/apt/stats/weekly/"$year"-"$month".html"
        if curl --output foo --silent --fail $url; then
            cat foo | perl -pe 's/<tr>/\n/g;' | grep '>hfst<' | perl -pe 's/[^0-9]*([0-9]+)[^0-9]*([0-9]+)[^0-9]*([0-9]+)[^0-9]*([0-9]+)[^0-9]*/\1 \2 \3 \4/;' >> results
            echo "" >> results
        fi
    done
done

col=1
for field in "Total" "Linux" "Win" "Mac";
do
    cut -d' ' -f$col results | perl -pe 's/\n/ + /g;' | perl -pe 's/(.*) \+ /\1/;' > foo
    echo "" >> foo
    echo $field": "
    cat foo | bc
    col=$((col+1))
done