linux—如何在从文件读取的配置单元查询中传递变量作为表名

w51jfk4q  于 2021-06-24  发布在  Hive
关注(0)|答案(1)|浏览(263)

我正在编写shell脚本,它将从文件中读取表名,并将表名传递给配置单元查询。
但我想 $ 在Hive中不被识别。
知道如何在配置单元查询中传递变量吗?
错误:无法识别$i附近的输入


# !/bin/bash

# Input file

ifile="/tmp/table.txt" 

if [[ -f "$ifile" ]]
then
  while IFS= read -r i
    hive -e "show create table $i"
  done <"$ifile"
fi

$cat表格.txt

office.empoyee
office.department
office.floor
yzuktlbb

yzuktlbb1#

我想这里缺少的只是 do 之后 while 生产线:

if [[ -f "$ifile" ]]
then
  while IFS= read -r i
  do
    hive -e "show create table ${i}"
  done <"$ifile"
fi

相关问题