【问题标题】:How to check if a directory exist, within a shell script? [duplicate]如何在 shell 脚本中检查目录是否存在? [复制]
【发布时间】:2014-03-30 17:50:54
【问题描述】:

在 shell 脚本中可以使用什么命令来检查目录是否存在?

【问题讨论】:

  • 下次,亲爱的@ayyappa,当你输入你的标题时,看看建议的旧帖子;-)

标签: unix


【解决方案1】:
if [ -d "/path/to/dir" ]
then
      echo "Directory /path/to/dir exists."
else
      echo "Error: Directory /path/to/dir does not exists."
fi

【讨论】:

    猜你喜欢
    • 2017-01-12
    • 1970-01-01
    • 2011-11-23
    • 2022-11-23
    • 2016-07-14
    • 2012-02-06
    • 2018-03-16
    • 1970-01-01
    • 2014-03-06
    相关资源
    最近更新 更多