Check if a directory exists in a shell script

在shell脚本中可以使用什么命令来检查目录是否存在? To check if a directory exists in a shell script you can use the following: if [ -d "$DIRECTORY" ]; then # Control will enter here if $DIRECTORY exists. fi Or to check if a directory doesn't exist: if [ ! -d "$DIRECTORY" ]; then # Control will enter here if $DIRECTORY doesn't exist. fi However, as Jon Ericson points out (thanks Jon), s

检查一个目录是否存在于一个shell脚本中

在shell脚本中可以使用什么命令来检查目录是否存在? 要检查目录是否存在于shell脚本中,可以使用以下命令: if [ -d "$DIRECTORY" ]; then # Control will enter here if $DIRECTORY exists. fi 或者检查一个目录是否不存在: if [ ! -d "$DIRECTORY" ]; then # Control will enter here if $DIRECTORY doesn't exist. fi 然而,正如Jon Ericson所指出的(感谢Jon),如果您不考虑到目录的符号链接也会通过此检查,则后