如何查找文件夹是否存在于 hadoop 中?

How to find if a folder exists in hadoop or not?

我需要查找输入文件夹位置是否存在于 hadoop 中。

我正在使用以下命令执行相同的操作

 hadoop fs -test -d <folder Location> 

查询没有抛出任何错误,也没有输出。我已经检查了它的正确和错误位置。我从文档中了解到,如果位置正确,它应该输出 1。

hdfs dfs -test -d <folder location> 不输出任何内容,如 01。关于退出状态,0代表目录存在时的正常情况。 1 表示缺少目录。

这是您可以在 bash 中使用的示例:

hdfs dfs -test -d /tmp && echo 'dir exists' || echo 'sorry, no such dir'

感谢@Mikhail Golubtsov。使用上面的提示,我最终修改的 shell 脚本是

if hadoop fs -test -d   ;
then echo "yeah it's there "
else
echo  "No its not there." 

fi