bash—以表名为参数并执行配置单元查询来编写shell脚本

nkkqxpd9  于 2021-06-26  发布在  Hive
关注(0)|答案(1)|浏览(354)

我正在尝试构建一个shell脚本,它以表\u name作为参数,并运行下面的配置单元查询。

INSERT OVERWRITE DIRECTORY '/data/table_name' 
row format delimited
FIELDS TERMINATED BY ','
SELECT * FROM table_name
vngu2lb8

vngu2lb81#

也许你需要它:


# !/bin/bash

if [ -z "$1" ]; then exit 1; fi    
printf -v TAB "%q" "$1"
/usr/bin/mysql -NBe "INSERT OVERWRITE DIRECTORY '/data/table_$TAB' row format delimited FIELDS TERMINATED BY ',' SELECT * FROM $TAB"

相关问题