sh脚本判断路径是否存在

 (1)判断是否存在:

#!/bin/bash

if [ -d "/path/to/directory" ]; then
    echo "Directory exists"
else
    echo "Directory does not exist"
fi

 (2)判断不存在:

if [ ! -d "/path/to/directory" ]; then
    echo "Directory does not exist"
fi

 

posted @ 2024-05-29 09:18  远方是什么样子  阅读(22)  评论(0编辑  收藏  举报