Home >Database >Mysql Tutorial >hadoop判断文件是否存在

hadoop判断文件是否存在

WBOY
WBOYOriginal
2016-06-07 14:58:551587browse

hadoop判断文件是否存在 在shell中判断一个HDFS目录/文件是否存在 直接看shell代码: hadoop fs -test -e /hdfs_dir if [ $? -ne 0 ]; then echo Directory not exists! fi hadoop fs -test -e 用于判断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] : If file { exists, has zero length, is a directory

then return 0, else return 1.

 

e,z,d参数必用其一,不可缺少。

 

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn