文件存在判断
linux本地文件:
shell脚本:
#判断目录是否存在
if [ -d "/data/hadoop/data/my/2019/08" ]; then echo yes! else echo no! fi
#判断文件是否存在 if [ -e "/data/hadoop/data/my/2019/08/exits.csv" ]; then echo yes! else echo no! fi
hdfs文件 :
#判断hdfs文件是否存在 hdfs dfs -test -d /log/giffront if [ $? -eq 0 ]; then echo "is directory" else echo "is not directory" fi #判断是否为文件 hdfs dfs -test -f /log/giffront if [ $? -eq 0 ]; then echo "is file" else echo "is not file" fi