-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpostprocess.sh
executable file
·88 lines (52 loc) · 1.77 KB
/
postprocess.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
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/bash
OUT_FOLDER=$1
mkdir -p $OUT_FOLDER
echo "analyze"
cat std.out | grep "VAR" | sed 's/VAR://g' > $OUT_FOLDER/variables.out
cat std.out | grep "OP" | sed 's/OP://g' > $OUT_FOLDER/operators.out
for outfile in $OUT_FOLDER/out_*
do
cat $outfile | grep "STATE" | sed 's/STATE://g'>> $OUT_FOLDER/states.out
done
filenamelist=(out_*)
count=${#filenamelist[@]}
count=$((count-1))
echo "agents 0 - $count"
for agent in `seq 0 $count`
do
echo "AGENT $agent"
OUT="$OUT_FOLDER/agent${agent}.json"
echo "output=$OUT"
echo $'{\n' > $OUT
echo $'\"variables\":[' >> $OUT
cat $OUT_FOLDER/variables.out | grep "\"agentID\":$agent" | head -n -1 > $OUT_FOLDER/temp
while read LINE
do echo "$LINE," >> $OUT
done < $OUT_FOLDER/temp
cat $OUT_FOLDER/variables.out | grep "\"agentID\":$agent" | tail -n 1 >> $OUT
echo $'],\n' >> $OUT
echo $'\"operators\":[' >> $OUT
cat $OUT_FOLDER/operators.out | grep "\"agentID\":$agent" | head -n -1 > $OUT_FOLDER/temp
while read LINE
do echo "$LINE," >> $OUT
done < $OUT_FOLDER/temp
cat $OUT_FOLDER/operators.out | grep "\"agentID\":$agent" | tail -n 1 >> $OUT
echo $'],\n' >> $OUT
echo $'\"states\":[' >> $OUT
cat $OUT_FOLDER/states.out | grep "\"agentID\":$agent" | head -n -1 > $OUT_FOLDER/temp
while read LINE
do echo "$LINE," >> $OUT
done < $OUT_FOLDER/temp
cat $OUT_FOLDER/states.out | grep "\"agentID\":$agent" | tail -n 1 >> $OUT
echo $'],\n' >> $OUT
echo $'\"plan\":[' >> $OUT
#cat plan.out
cat plan.out | tr '()' '\"\"' | head -n -1 > $OUT_FOLDER/temp
while read LINE
do echo "$LINE," >> $OUT
done < $OUT_FOLDER/temp
#cat $OUT_FOLDER/temp
cat plan.out | tr '()' '\"\"' | tail -n 1 >> $OUT
echo $']\n}' >> $OUT
rm $OUT_FOLDER/temp
done