我在Linux
中有一个文件。该文件包含表格名称。根据条件在Linux中创建新文件
现在我想检查这个文件并根据条件创建文件。
table=${}
validateTable=$(hive --database "${hivedb}" -e "SHOW TABLES LIKE '$table'")
if [[ -z $validateTable ]]; then
Add to file New_imports
else
Add to file Already exists
fi
例如:
该文件包含
table1
table2
table3
table4
在上述表table1
和table2
已经现有。
所以我想两个文件
1)New_imports为不存在的 2表)已经存在,存在
new_imports
table3
table4
already exists
table1
table2
表
我该如何交流hieve我的结果
#!/bin/bash while read table ; do table=${1:1:-1} validateTable=$(hive --database "${hivedb}" -e "SHOW TABLES LIKE '$table'") if [[ -z $validateTable ]]; then echo "$table" >> New_imports else echo "$table" >> Already_exists fi done < tableFile
不知道为什么有人甚至低估你的原始Q.哦,好! – shellter