-test -[defsz] 测试文件是否存在:
Answer various questions about , with result via exit status.
-d return 0 if is a directory.
-e return 0 if exists.
-f return 0 if is a file.
-s return 0 if file is greater than zero bytes in size.
-z return 0 if file is zero bytes in size, else return 1.
查看文件是否为空,则用-s
hadoop fs -test -s /user/hive/ch_tv_data/usrp_basic_info
if [ $? -ne 0 ]; then
echo "Directory not exists!"
else
echo "OK"
fi