[root@node00 ~]# hdfs dfs -help...
-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 iffile<path> is greater than zero bytes in size.
-z return 0 iffile<path> is zero bytes in size, elsereturn 1.
...
#!/bin/bash
hdfs dfs -test -e /path/exist
if[$ -eq 0 ];thenecho'exist'elseecho'Error! NO Such File Or Directory !'fi...
test 命令还可以判断:**
-d某个路径是否是文件夹( -d);
-f某个路径是否是文件( -f);
-s某个文件大小是否大于0;
-z某个文件大小等于0
#!/bin/bash#判断是否是文件夹
hdfs dfs -test -d /path/exist
if[$ -eq 0 ];thenecho'Is a directory'elseecho'Is not a directory'fi#判断是否是文件
hdfs dfs -test -f /path/exist
if[$ -eq 0 ];thenecho'Is a file'elseecho'Is not a file'fi#判断文件大小是否大于0
hdfs dfs -test -s /path/exist
if[$ -eq 0 ];thenecho'Is greater than zero bytes in size'elseecho'Is not greater than zero bytes in size'fi#判断文件大小是否等于0
hdfs dfs -test -z /path/exist
if[$ -eq 0 ];thenecho'Is zero bytes in size.'elseecho'Is not zero bytes in size. 'fi