我有一个包含以下内容的脚本:
DBName=db_1;
showcreate="show create table "
showpartitions="show partitions "
terminate=";"
tables=`hive -e "use $DBName;show tables;"`
tab_list=`echo "${tables}"`
DBname是一个变量,用于保存在其中输入的数据库名称。
要运行此脚本,请在命令行上使用以下命令:
cmod +x /home/file1.sh
./file1.sh
有什么方法可以从命令行脚本中输入变量“ DBname”名称的值?因此,例如,在命令行上,它看起来像这样:
./file.sh db_2
并且在脚本运行时,它将输入(db_2)作为DBname变量的值。