使用 macOS 终端在子目录中查找目录

Pra*_*Das 3 directory find macos

x我想使用 macOS 终端在特定子目录中查找目录y,但我不知道y.

该命令find / -type d -name "x"适用于查找,但系统中x有许多命名的目录,因此我需要查找该目录下的目录。xxy

我试过 -

  • find / -type d -name "/y/x"或者
  • find / -type d -name "y/x"或者
  • find / -type d -name "../y/x"

但这些并没有告诉我想要的结果。

jes*_*e_b 7

使用-path初级:

find / -path '*y/x'
Run Code Online (Sandbox Code Playgroud)
-path pattern
         True if the pathname being examined matches pattern.  Special shell pattern matching characters (``['', ``]'', ``*'', and ``?'') may be used as part of
         pattern.  These characters may be matched explicitly by escaping them with a backslash (``\'').  Slashes (``/'') are treated as normal characters and do
         not have to be matched explicitly.
Run Code Online (Sandbox Code Playgroud)