-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcard.sh
72 lines (58 loc) · 1.53 KB
/
card.sh
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
69
70
71
#!/bin/sh
# -b: batters
# -p: pitchers
# -d: data directory
# -w: use -w flag with egrep (exact match)
year="2011"
dir="/home/ibl/iblgame/${year}/build"
if [ -f $HOME/.card ]; then
. $HOME/.card
fi
usage() {
echo "usage: $0 { -b | -p } player"
exit 1
}
while getopts bpwd: opt; do
case $opt in
p) if [ $awkf ]; then
usage
else
awkf=${dir}/d1.genpit
fi
;;
b) if [ $awkf ]; then
usage
else
awkf=${dir}/d1.genbat
fi
;;
d) dir=$OPTARG
;;
w) match="-w"
;;
*) usage
;;
esac
done
if [ ! $awkf ]; then
usage
fi
shift `expr $OPTIND - 1`
echo $awkf | grep -q pit
if [ $? -eq 0 ]; then
echo "Player 1B 2B DF HB BB IFR OFR H OB XB"
for player in $*; do
egrep $match -i "$player" $awkf | awk '{ printf "%-3s %-12s vL %4d%4d%4d%4d%4d%4d%4d - %4d%4d%4d\n",
$1, $2, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26 }'
egrep $match -i "$player" $awkf | awk '{ printf "%-3s %-12s vR %4d%4d%4d%4d%4d%4d%4d - %4d%4d%4d\n",
$1, $2, $28, $29, $30, $31, $32, $33, $34, $35, $36, $37 }'
done
else
echo "Player 1B 2B 3B HR HB BB H OB XB Pw"
for player in $*; do
egrep $match -i "$player" $awkf | awk '{ printf "%-3s %-12s vL %4d%4d%4d%4d%4d%4d - %4d%4d%4d %3s\n",
$1, $2, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24 }'
egrep $match -i "$player" $awkf | awk '{ printf "%-3s %-12s vR %4d%4d%4d%4d%4d%4d - %4d%4d%4d %3s\n",
$1, $2, $26, $27, $28, $29, $30, $31, $32, $33, $34, $35 }'
done
fi