1
林很新的shell脚本。我在shell脚本中运行了下面的sqoop命令并得到了结果。在shell脚本传递两个参数到shell脚本
sqoop命令
#!/bin/bash
while read table; do
sqoop eval --connect jdbc:mysql://127.0.0.1/mydb --username root --password cloudera --query "describe $table"
done<tables.txt
输入文件:tables.txt只有一个字:MYTAB和IM流汗了这一结果。
但是我怎么能写一个脚本从文件中取两个参数,当tables.txt中的数据看起来像这样:MYDB:MYTAB,并且我想将dbname和表名传递给脚本中的sqoop命令,看起来像下面。
#!/bin/bash
while read table; do
sqoop eval --connect jdbc:mysql://127.0.0.1/$dbname --username root --password cloudera --query "describe $table"
done<tables.txt
谁能告诉我如何提取从文件中的值,并把它们在文件中?
++超快速的答案:) – anubhava
@anubhava后:没办法那么快你_sir_!感谢您的补充! – Inian
它正在工作。如果有多个参数,我们可以给出 ,而IFS =“:”读取-r dbname table arg3 arg;请在我们的命令中使用它们。这非常清楚,谢谢! – Sidhartha