(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