阅读量:60
在HDFS中,可以使用以下命令来判断目录是否存在:
hadoop fs -test -d hdfs://:/
如果目录存在,命令将返回0;如果目录不存在,命令将返回1。您也可以使用if语句来根据返回值来判断目录是否存在,例如:
if hadoop fs -test -d hdfs://:/; then
echo "Directory exists"
else
echo "Directory does not exist"
fi