Home [Shell] 날짜 범위 지정해서 실행
Post
Cancel

[Shell] 날짜 범위 지정해서 실행

  • 입력
    • staratdate
    • enddate
1
2
3
4
5
6
7
8
9
10
11
startdate='20210701'
enddate='20210707'

enddate=$( date -d "$enddate + 1 day" +%Y%m%d )   # rewrite in YYYYMMDD format
                                                  #  and take last iteration into account
thedate=$( date -d "$startdate" +%Y%m%d )
while [ "$thedate" != "$enddate" ]; do
    printf 'The date is "%s"\n' "$thedate"
    beeline --hivevar DATE=$thedate -f query.hql
    thedate=$( date -d "$thedate + 1 days" +%Y%m%d ) # increment by one day
done
1
2
3
4
5
6
7
8
9
10
11
12
startdate='2021-07-01'
enddate='2021-07-07'

enddate=$( date -d "$enddate + 1 day" +%Y-%m-%d )
thedate=$( date -d "$startdate" +%Y-%m-%d )

while [ "$thedate" != "$enddate" ]; do
    printf 'The date is "%s"\n' "$thedate"
    beeline --hivevar DATE=$thedate -f query.hql
    thedate=$( date -d "$thedate + 1 days" +%Y-%m-%d ) # increment by one day
done

This post is licensed under CC BY 4.0 by the author.

[Hive] External Partitioned Table (CREATE, INSERT, ALTER)

VS Code Extentions