(1)编写脚本如下,HDFS路径自己传入

vim test.sh
#!/bin/bash
path=$1
hadoop fs -test -e $path
if [ $? -eq 0 ];then
echo "Path is exit!"
else
echo "Path is not exist!"
fi

(2)执行脚本如下

sh test.sh /root/usr/dem.csv
Path is exit!

(3)注意

脚本中空格非常重要:
比如说:
​​​if [$REDIS_SENTINEL_ENABLE -eq 1]; then​​​应该写成
​​​if [ $REDIS_SENTINEL_ENABLE -eq 1 ]; then​​​(方括号前后有空格,then之前有空格)的
在if判断中[]这个符号有特殊要求。里面与代码之间要有空格隔开的。