[英]bash script: check if directory name exists anywhere (not just in current path)?
How would I check if a directory name exists anywhere on a machine (not limited to the current working directory/subdirectories)? 如何检查计算机上任何地方的目录名称(不限于当前的工作目录/子目录)? I'm using -d right now, but this only lets me know if the directory exists within the path I'm currently on.
我现在正在使用-d,但这仅让我知道目录是否存在于我当前所在的路径中。
example input: 输入示例:
./file.sh hello
expected: 预期:
script will search through computer to see if there's a directory
anywhere named "hello" and return "yes"
This should work 这应该工作
#!/bin/bash
find / -name "$1" -type d -print
Expect a lot of Permission denied
errors if not running from root 如果不是从根目录运行,则会出现很多“
Permission denied
错误
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.