linux 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
# 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
# Control will enter here if $DIRECTORY doesn't exist.
fi
posted on 2020-09-25 11:11 paulwong 閱讀(384) 評論(0) 編輯 收藏 所屬分類: LINUX 、LINUX-SHELL