这是我的代码,它可以工作,但它总是说目录存在,无论我写的是什么。此外,它不会在echo $DIRECTORY
中打印变量。我需要修理什么?
#!/bin/sh
if [ -d $DIRECTORY ]; then
echo "Directory exists"
elif [ ! -d $DIRECTORY ]; then
echo "Directory does not exists"
fi
echo $DIRECTORY
答案 0 :(得分:3)
样品:
#!/bin/sh
DIRECTORY="$1"
if [ -d "$DIRECTORY" ]; then
echo "Directory '$DIRECTORY' exists"
else
echo "Directory '$DIRECTORY' does not exists"
fi
echo $DIRECTORY