hadoop判斷文件是否存在
在shell中判斷一個HDFS目錄/文件是否存在
直接看shell代碼:
hadoop fs -test -e /hdfs_dir
if [ $? -ne 0 ]; then
echo "Directory not exists!"
fi
hadoop fs -test -e 用於判斷HDFS目錄/文件是否存在,下一步檢測該命令的返回值,以確定其判斷結果。
-test -[ezd] <path>: If file { exists, has zero length, is a directory
then return 0, else return 1.
e,z,d參數必用其一,不可缺少。