shell判断文件夹是否存在

To check if a directory exists in shell, you can use the test command with the -d option. For example:

if test -d /path/to/directory; then
  echo "Directory exists"
else
  echo "Directory does not exist"
fi

This checks whether the directory at /path/to/directory exists, and if it does, the echo command will print "Directory exists". Otherwise, it will print "Directory does not exist".

Alternatively, you can use the [ -d /path/to/directory ] syntax, which has the same effect:

if [ -d /path/to/directory ]; then
  echo "Directory exists"
else
  echo "Directory does not exist"
fi

These examples assume you are using a Bourne-style shell, such as bash. The exact syntax may vary depending on the shell you are using.