-
Notifications
You must be signed in to change notification settings - Fork 1
/
results.sh
executable file
·72 lines (62 loc) · 1.68 KB
/
results.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
72
#! /bin/bash
#signature
signature='
$$\ $$\ $$\ $$\ $$$$$$\ $$$$$$\
$$ | $$ |$$$\ $$ |$$ __$$\ $$ __$$\
$$ |$$ / $$$$\ $$ |\__/ $$ |$$ / \__|
$$$$$ / $$ $$\$$ | $$$$$$ |$$ |
$$ $$< $$ \$$$$ |$$ ____/ $$ |
$$ |\$$\ $$ |\$$$ |$$ | $$ | $$\
$$ | \$$\ $$ | \$$ |$$$$$$$$\ \$$$$$$ |
\__| \__|\__| \__|\________| \______/
----------------------------------------
'
DIR=`dirname $0`
main() {
echo "$signature"
resultsDir=`tail -n 1 $DIR/data/path.txt`
savePath=""
declare -i saveFlag=0
read -t 10 -p "Do you want to save results in a file? (y/n): " doSave
echo
if [[ ${doSave[0]} == 'y' ]] || [[ ${doSave[0]} == 'Y' ]] ; then
read -t 30 -p "Enter path of the save File: " savePath
if ! [[ -n $savePath ]] ; then
savePath="$DIR/Saved_Results.txt"
fi
saveFlag=1
echo $savePath
fi
read -t 10 -p "Enter tag of the results you want: " tag
echo
if ! [[ -n $tag ]] ; then
if [[ -r "$resultsDir/Results.txt" ]] ; then
declare -i i=0
while IFS= read -r line ; do
i=`expr index $line ": "`
game=${line:$i}
i=`expr index $line "---"`
tag=${line:0:$i-1}
echo "$game -> $tag"
if [[ $saveFlag -eq 1 ]] ; then
echo "$game -> $tag" >>$savePath
fi
done < $resultsDir/Results.txt
fi
else
if [[ -d $resultsDir/$tag ]] && [[ -r $resultsDir/$tag/Results.txt ]] ; then
declare -i i=0
while IFS= read -r line ; do
tmp=$line
i=`expr index $tmp ": "`
tmp=${tmp:$i}
echo $tmp
if [[ $saveFlag -eq 1 ]] ; then
echo "$tmp" >>$savePath
fi
done < $resultsDir/$tag/Results.txt
fi
fi
}
#
main