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
(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