-
Notifications
You must be signed in to change notification settings - Fork 1
/
status
executable file
·44 lines (37 loc) · 1.25 KB
/
status
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
#!/bin/sh
#
if [ -n "$1" -a "$1" = "-h" ] ; then
echo "Usage: status [options]"
echo "Show the status of questions for the red-green trivia game"
echo "Options:"
echo " -h Show usage help"
echo " -v Show verbose data (each question line)"
echo " -r Show remaining questions"
echo " -i Show integrated questions (in order)"
exit 1
fi
if [ -n "$1" -a "$1" = "-v" ] ; then
echo "== Questions integrated =="
grep "^Q" ELC-2021-trivia.txt | grep Q[.][0-9]
echo "== Questions remaining =="
grep "^Q" ELC-2021-trivia.txt | grep -v Q[.][0-9]
echo "========================"
shift
fi
if [ -n "$1" -a "$1" = "-r" ] ; then
echo "== Questions remaining =="
grep "^Q" ELC-2021-trivia.txt | grep -v Q[.][0-9]
echo "========================"
shift
fi
if [ -n "$1" -a "$1" = "-i" ] ; then
echo "== Questions remaining =="
grep "^Q" ELC-2021-trivia.txt | grep Q[.][0-9] | sed s/Q.// | sort -n
echo "========================"
fi
echo -n "Number of questions integrated: "
grep "^Q" ELC-2021-trivia.txt | grep Q[.][0-9] | wc -l
echo -n "Number of questions remaining: "
grep "^Q" ELC-2021-trivia.txt | grep -v Q[.][0-9] | wc -l
echo -n "Total number of questions: "
grep ^Q ELC-2021-trivia.txt | wc -l