forked from jcosborn/qhmc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gettag
executable file
·68 lines (62 loc) · 968 Bytes
/
gettag
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/sh
p='$i'
if [ "X$1" = "X-p" ]; then
p="$2"
shift 2
fi
tag=$1
shift
if [ "X$tag" = "X" ]; then
echo "$0 <tag> <files...>"
exit -1
fi
fs=`\ls -1 "$@" |sort -n -t . -k 2`
echo $fs
get() {
for f in $fs; do
grep "$tag" $f
done
}
ave() {
awk '
{
for(i=1; i<=NF; i++) {
n[i] += 1;
v = '$p';
s[i] += v;
s2[i] += v*v;
l[i] = $i;
}
}
END{
printf("# N = %i\n", n[1]);
for(i=1; n[i]>0; i++) {
if(match(l[i],"[a-zA-Z:=]")>0) {
printf("%s ", l[i]);
} else {
printf("%-12.6g ", s[i]/n[i]);
}
}
printf("\n");
for(i=1; n[i]>0; i++) {
if(match(l[i],"[a-zA-Z:=]")>0) {
printf("%*c ", length(l[i]), " ");
} else {
a = s[i]/n[i];
a2 = s2[i]/n[i];
e = sqrt((a2-a*a)/(n[i]-1));
printf("%-12.6g ", e);
}
}
printf("\n");
}
'
}
n=`get |wc -l`
n9=$((9*n/10))
n8=$((8*n/10))
n2=$((n/2))
get |ave
get |tail -n $n9 |ave
get |tail -n $n8 |ave
get |tail -n $n2 |ave