Shell变量获取Hive返回值

while循环的使用,

if循环的使用,

执行hive语句并赋值给shell变量 

grep过滤无效字符的使用

hive.cli.print.header可以控制在cli中是否显示表的列名

 counts0=`hive -e "set hive.cli.print.header=false;select case when count(1) > 0 then 1 else 0 end count from dwb.mid_organizationsnapshot_1 where effectivedate='${current_date}' and company='${company}';" | grep -v WARN`

#!/bin/bash
start_date=$1
end_date=$2
company=$3
 
#while循环的使用,注意[] 这两个符号内侧都要留有空格
while [ "$start_date" -le "$end_date" ];
do
  current_date=`date -d "$start_date" +%Y-%m-%d`
  echo $company
  echo "current_date====$current_date"
 
  #这里切记要注意赋值给变量时,=号左右两侧不要有空格ÿ

你可能感兴趣的:(Hive,Shell)