判斷HDFS文件是否存在


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參數必用其一,不可缺少。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM