标签:text exist tor div path targe echo 判断 ado
用于检测文件或目录是否存在,判断文件或目录大小。
-test -[defsz] <path> : Answer various questions about <path>, with result via exit status. -d return 0 if <path> is a directory. -e return 0 if <path> exists. -f return 0 if <path> is a file. -s return 0 if file <path> is greater than zero bytes in size. -z return 0 if file <path> is zero bytes in size. else return 1.
用例:
1.判断文件或目录是否存在
hadoop fs -test -e /hive/warehouse/test/
echo $? #获取最近一次调用的返回值 0表示存在,1表示不存在
2.判断文件或目录大小是否为0
hadoop fs -text -z /hive/warehouse/test/tmp echo $? #0表示文件或目录大小为0
【参考资料】
[1]. https://hadoop.apache.org/docs/r2.6.0/hadoop-project-dist/hadoop-common/FileSystemShell.html#text.
标签:text exist tor div path targe echo 判断 ado
原文地址:https://www.cnblogs.com/walker-/p/11010983.html