在Linux系统中,可以使用一些命令来判断文件夹是否存在,其中比较常用的是使用test命令或者-d参数。
if test -d /path/to/directory; then
echo "Directory exists"
else
echo "Directory does not exist"
fi
if [ -d /path/to/directory ]; then
echo "Directory exists"
else
echo "Directory does not exist"
fi
以上两种方式都可以用来判断文件夹是否存在,只需要将/path/to/directory替换为你要判断的文件夹路径即可。如果文件夹存在,则会输出"Directory exists",否则会输出"Directory does not exist"。
辰迅云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读: 如何使用Linux命令行调整摄像头参数