bash脚本:检查目录名是否存在于任何地方(不仅仅是当前路径)?

时间:2018-01-10 21:16:08

标签: bash directory

如何检查计算机上的目录名是否存在(不限于当前工作目录/子目录)?我现在正在使用-d,但这只让我知道该目录是否存在于我当前所在的路径中。

示例输入:

./file.sh hello

预期:

script will search through computer to see if there's a directory 
anywhere named "hello" and return "yes" 

1 个答案:

答案 0 :(得分:0)

这应该有效

#!/bin/bash
find / -name "$1" -type d -print  

如果从root运行

,则会出现很多Permission denied错误