蜂巢和数据库之间的完整性检查
Currently I have a bash script that does a basic row count to a hive table (stores result in a variable), then another row count to a mysql table. Bash then evaluates the 2 variables. No problems here so far.
目前我有一个bash脚本,它对hive表执行基本行计数(将结果存储在变量中),然后将另一行计数到mysql表。然后Bash评估2个变量。到目前为止没有任何问题。
There is anotherScript.sh in which has listed about 50 table names.
eg. target_tables=" name_table1
name_table2
name_table3
... and so on.
还有另一个Script.sh,其中列出了大约50个表名。例如。 target_tables =“name_table1 name_table2 name_table3 ...依此类推。
I'd imagine this would need a for loop to automate the above script to run through all the 50 tables in a single command? How do I tell my script to pick out the table names from anotherScript.sh?
我想这需要一个for循环来自动执行上面的脚本来运行单个命令中的所有50个表?如何告诉我的脚本从anotherScript.sh中选择表名?
1 个解决方案
#1
1
To loop through the variable, you can have:
要遍历变量,您可以:
for table in $target_tables; do
(do something with $table)
done
If your table names contain spaces, use IFS=$'\n'
:
如果表名包含空格,请使用IFS = $'\ n':
(
IFS=$'\n'
for table in $target_tables; do
(do something with $table)
done
)
If you're using bash 4.0+ the safest would be:
如果您使用bash 4.0+,最安全的将是:
readarray -t tables <<< "$target_tables"
for table in "${tables[@]}"; do
(do something with $table)
done
更多相关文章
- c语言把mysql数据库语句和变量封装为一个语句
- JavaScript中当前脚本的URL
- 范围变量值的变化没有反映在我的字符串中
- 开心菜鸟系列----变量的解读(javascript入门篇)
- 如何让Require.js获取一个不以`.js`结尾的脚本? [重复]
- 如何使用变量创建数组?
- Angularjs:如何将范围变量传递给指令?
- 如何将razor变量传递给js
- 使用没有后端脚本的Angularjs上传文件(例如PHP,JAVA等)