UNIX 命令行 - 如何使用嵌入式通配符 "find" 目录
UNIX Command Line - How to "find" directories using embedded wildcard
我想在名为 "2"
的 UNIX 服务器上查找 all/any 个目录,但我只希望它们位于特定目录结构名称 "/home/abc/public_html"
.
中
我试过这个:
find / -type d -name "/home/abc/public_html/*2"
但是我得到了错误
find: warning: Unix filenames usually don't contain slashes (though
pathnames do).
添加条件 -a
:
find . -name '*/home/abc/public_html/*' -a -name '*2'
或者,如评论中所示:
find / -type d -wholename "*/home/abc/public_html/*2"
因为您遇到了错误
find: warning: Unix filenames usually don't contain slashes (though
pathnames do). That means that '-name /home/vps/public_html/'' will
probably evaluate to false all the time on this system. You might find
the '-wholename' test more useful, or perhaps '-samefile'.
Alternatively, if you are using GNU grep, you could use 'find ...
-print0 | grep -FzZ /home/vps/public_html/''."
我想在名为 "2"
的 UNIX 服务器上查找 all/any 个目录,但我只希望它们位于特定目录结构名称 "/home/abc/public_html"
.
我试过这个:
find / -type d -name "/home/abc/public_html/*2"
但是我得到了错误
find: warning: Unix filenames usually don't contain slashes (though pathnames do).
添加条件 -a
:
find . -name '*/home/abc/public_html/*' -a -name '*2'
或者,如评论中所示:
find / -type d -wholename "*/home/abc/public_html/*2"
因为您遇到了错误
find: warning: Unix filenames usually don't contain slashes (though pathnames do). That means that '-name /home/vps/public_html/'' will probably evaluate to false all the time on this system. You might find the '-wholename' test more useful, or perhaps '-samefile'. Alternatively, if you are using GNU grep, you could use 'find ... -print0 | grep -FzZ /home/vps/public_html/''."