#!/bin/bash
#日志目录
#shell判断表hive表是否存在
#TABLE=库名.表名
TABLE=dal.dal_mdn_communication_behavior
hive -e"
desc $TABLE;
" 2>&1 | grep 'Table not found'
rtstatus=$?
echo $rtstatus
if [ $rtstatus -ne 0 ]; then
echo "hbase表已存在!"
else
echo "hbase表不存在!"
fi
或者
#!/bin/bash
touch test.txt
if [ $? -eq 0 ] then echo "执行成功"
else echo "执行失败"
fi
echo $?
原文:https://blog.csdn.net/qq_36740035/article/details/82689463