0
  date=20190901


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

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

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

20190901
20190801
20190701
20190620
20190515

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

4

1 回答 1

0

你有正确的想法。这是一个帮助语法的脚本。

#!/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
于 2020-02-26T17:14:52.700 回答