/
cmb-getdates.sh
61 lines (61 loc) · 1.37 KB
/
cmb-getdates.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
source ~/.bashrc
arg1="$1"
simfile=""
if [ "$arg1" = "sim" ]
then
simfile="sim"
elif [[ "$arg1" = *"safety"* ]]
then
simfile="$arg1"
fi
if [ "$2" != "" ]
then
arg2=$2
fi
if [[ "$arg1" = "" || "$arg1" = "s3" || "$arg1" = "sim" || "$arg1" = "1" || "$arg1" = "2" || "$arg1" = "3" || "$arg1" = "4" || "$arg1" = *"safety"* ]]
then
cmbdates=""
IFS=$'\n'
if [ "$arg1" = "1" -o "$arg1" = "2" -o "$arg1" = "3" -o "$arg1" = "4" ]
then
echo $simfile
end=`expr $arg2 + 1`
start=`expr $arg2 + 1 - $arg1`
grabbingdates="tail -n+2 ${simfile}getdates.csv | sed -n \"$start,$end"
grabbingdates=$grabbingdates"p\" ${simfile}getdates.csv | sed 's/,/ /g'"
echo $grabbingdates
else
grabbingdates="tail -n+2 ${simfile}getdates.csv | sed 's/,/ /g'"
fi
for row in $(eval $grabbingdates)
do
IFS=$' '
set -- $row
if [ "$cmbdates" = "" ]
then
if [ "$arg1" = "sim" ]
then
cmbdates="(t >= ($2 _ 1000) && t <= ($3 _ 1000))"
else
cmbdates="(t >= $2 && t <= $3)"
fi
firststart=$2
else
if [ "$arg1" = "sim" ]
then
#cmbdates="$cmbdates || (t >= ($2 "'* 1000) && t <= ('"$3 "'* 1000))'
cmbdates="$cmbdates || (t >= ($2 _ 1000) && t <= ($3 _ 1000))"
else
cmbdates="$cmbdates || (t >= $2 && t <= $3)"
fi
fi
lastend=$3
done
if [ "$arg1" = "sim" ]
then
cmbdates="'"$cmbdates"'"
else
cmbdates=$cmbdates""
fi
echo $cmbdates
fi