1
votes

Hi I have the following code

#!/bin/bash

date=(2016-07-18-08,2016-07-18-09,2016-07-18-10)
date2=(2016-07-18-09,2016-07-18-10,2016-07-18-11)
timestamp=(1468832400000,1468836000000,1468839600000)

for ((i=0; i<${#date[@]}; i++))
  do
    for ((j=${timestamp[i]}; j<${timestamp[$((i+1))]}; j=j+900000))
       do
         hive -f analytics_scores.hql --hiveconf start=$j --hiveconf end=$j+900000 --hiveconf startdate=${date[i]} --hiveconf enddate=${date2[i]}
       done
  done

When I ran it, I got the following error:

((: j<: syntax error: operand expected (error token is "<")

It seems like there's something wrong with the 2nd parameter in my second for loop (j

I've looked through all the token errors, but, I can't find anything similar to this. Seems like there's something wrong with the "<" next to "$". Maybe it doesn't like that, but I can't figure out why or find a different way. Any help is appreciated.

Thanks!

1
Please take a look: shellcheck.net - Cyrus
Array elements are separated by whitespace, not commas. - chepner
@chepner why don't you post an answer - Jonas Berlin

1 Answers

1
votes

The loop is fine, your problem is your variables are not bash arrays. Try echo ${timestamp[1]}