我有一个需求,比如在shell脚本中将mysql查询结果用于配置单元查询,这是我在下面的代码中实现的
ctrl_tbl_date=`mysql -N -h ${Mysql_Host_Name} -u ${Mysql_Uname} -p${Mysql_pwd} -e "use ${MySQLDB};select max(Processing_Datetime) from ${Ctrl_Tbl}:"`
echo "$ctrl_tbl_date">>/edh_fw/scripts/sqoop_export_by_key/out_test6.txt
echo "taking the data which is satisfying below conditions"
temp=hive -v -e "set hive.exec.compress.output=false;insert overwrite directory '${temp_incremental_loc}' row format delimited fields terminated by '\t' stored as textfile select * from ${src_table} where createDate>'${ctrl_tbl_date}';"
echo "$temp">>/edh_fw/scripts/sqoop_export_by_key/out_test7.txt
我将每个值作为动态从我在脚本顶部初始化的执行行中传递。在这里,我没有将ctrl_tbl_date
放入配置单元查询中,当然MYSQL结果没有赋值给variable...Kindly,在这方面请帮助我
发布于 2018-07-01 05:28:55
使用
temp=$(hive -v -e "set hive.exec.compress.output=false;insert overwrite directory '${temp_incremental_loc}' row format delimited fields terminated by '\t' stored as textfile select * from ${src_table} where createDate>'${ctrl_tbl_date}';")
以便将内部查询的结果放在temp变量中...
现在,不使用$(),如下所示
temp=hive -v -e "set hive.exec.compress.output=false;insert overwrite directory '${temp_incremental_loc}' row format delimited fields terminated by '\t' stored as textfile select * from ${src_table} where createDate>'${ctrl_tbl_date}';"
你只是把写在右边的东西分配给左边,但实际上你想把右边的执行结果分配给左边……
https://stackoverflow.com/questions/51102635
复制相似问题