如何在命令行上通过Shell脚本运行变量(传递参数)

时间:2019-07-29 18:17:59

标签: shell unix command-line hive

我有一个包含以下内容的脚本:

 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变量的值。

0 个答案:

没有答案
相关问题