mktar: Use `wc` instead of `du` in summary message
[sunny256-utils.git] / epstat
blob61e0923dc55ea69b8e823b05e573eb26a1ed5d47
1 #!/bin/sh
3 #=======================================================
4 # epstat
5 # File ID: 7b2b204e-5d39-11df-88e3-90e6ba3022ac
6 # Lager enkel statistikk over hits osv i en loggfil.
7 # Forventer antall sekunder siden 1970 etterfulgt av TAB
8 # i begynnelsen av hver linje.
9 #=======================================================
11 tmp_file=/tmp/epstat.$RANDOM.tmp
12 wr_hours=1
13 wr_min=0
15 [ "$1" = "-m" ] && { shift; wr_min=1; } # -m lager minuttstatistikk også.
16 [ "$1" = "-t" ] && { shift; wr_hours=0; } # -t forhindrer utskrift av timebasis
18 cut -c 1-10 $* | sort -n | ep -l >$tmp_file
20 echo
21 echo Totalt $(wc -l $tmp_file | rmspcall | cut -d ' ' -f 1) hits.
23 echo Antall hits pr. døgn:
24 echo
25 uniq -cw 10 $tmp_file | tr T ' ' | cut -c 1-18 | perl -pe 's/^\s+(\d+)\s+(.*)$/$2\t$1/'
26 echo
28 if [ "$wr_hours" = "1" ]; then
29 echo Antall hits pr. time:
30 echo
31 uniq -cw 13 $tmp_file | tr [T:] ' ' | cut -c 1-21 | perl -pe 's/^\s+(\d+)\s+(.*)$/$2\t$1/'
34 if [ "$wr_min" = "1" ]; then
35 echo Antall hits pr. minutt:
36 echo
37 uniq -cw 16 $tmp_file | tr [T] ' ' | cut -c 1-24 | perl -pe 's/^\s+(\d+)\s+(.*)$/$2\t$1/'
40 rm $tmp_file