方法1

1
2
3
4
if [ ! -d "/root/test" ]; then
echo -e `date '+%Y-%m-%d %H:%M:%S %A'` "filepath doesn't exist "
mkdir -p /root/test
fi

方法2

1
2
3
4
5
filePath="test"
if [ ! -d "/root/${filePath}" ]; then
echo -e `date '+%Y-%m-%d %H:%M:%S %A'` "filepath doesn't exist "
mkdir -p /root/${filePath}
fi

http://example.com/2023/05/15/shell/【shell】(202305) 判断文件夹是否存在/
作者
ningan123
发布于
2023年5月15日
许可协议