如何在 shell 脚本中为此配置单元查询使用循环?

How to use a loop in a shell script for this hive query?

  date=20190901


  hql="select DISTINCT content from ods_tblog_content where dt==$dt"

  hive -e "$hql"> data/"content_$dt"

此脚本获取特定日期的数据,我将日期指定为 'Sept. 1, 2019'。如何使用循环获取每个月特定日期的内容?即:

20190901
20190801
20190701
20190620
20190515

我觉得我应该将这些日期放入一个数组中并使用循环来完成?我是 shell 脚本的新手。

你的想法是对的。这是一个有助于语法的脚本。

#!/bin/sh
hql="select DISTINCT content from ods_tblog_content where dt=${dt}"
#Array for desired dates
dates=(20190901 20190801 20190701 20190620 20190515)
for dt in ${dates[@]}
do 
hive -e "$hql" > /data/"content_${dt}"
done