I have the following arrays defined in a bash script
IFS=, read -r -a start_files <<< $(head -n 1 file.txt)
IFS=, read -r -a end_files <<< $(tail -n 1 file.txt)
I read also two values from a file
micro=1000000
IFS=#
[ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; }
while read start_time end_time
do
start_time=$(bc <<< "scale=6; $start_time/$micro")
end_time=$(bc <<< "scale=6; $end_time/$micro")
...
done < $INPUT
IFS=$OLDIFS
The values stored in the arrays and in start_time and end_time are epoch times, I mean values like 1361810326.840284000, 1361862515.600478000, 1361990369.166456000
In the "..." line I want to compare the values of start_time and end_time with all the values stored in an array in the following way
for i in `seq 0 116`;
do
if [ $start_time -ge ${start_files[$i]} && $start_time -le ${end_files[$i]}]; then
startF=$i
fi
done
for j in `seq 0 116`;
do
if [ $end_time -ge ${start_files[$j]} && $end_time -le ${end_files[$j]}]; then
endF = $j
fi
done
However this code yields a syntax error. What am I doing wrong?