find /bin -iname 'sh*' 不返回任何结果

eli*_*liu 3 command-line bash

问题是关于find命令的语法

me@222:~$ find /bin -iname 'sh*'
Run Code Online (Sandbox Code Playgroud)

不返回任何结果,同时:

me@222:/bin$ find -iname 'sh*'
Run Code Online (Sandbox Code Playgroud)

工作正常

设置信息:使用 putty 从 Windows 远程进入 ubuntu 20 LTS。

另外:
我想请求一种语法来正确查看 find 正在做什么。例如,它正在遍历的文件、它尝试匹配的确切路径或文件名字符串等。

ste*_*ver 10

在最近的 Ubuntu 系统上,是usrmerge的结果的/bin符号链接,并且该命令默认情况下不遵循符号链接。从:/usr/binfindman find

\n
   -P     Never follow symbolic links.  This  is  the  default  behaviour.\n          When find examines or prints information a file, and the file is\n          a symbolic link, the information used shall be  taken  from  the\n          properties of the symbolic link itself.\n\n   -L     Follow symbolic links.  [...]\n\n   -H     Do  not  follow symbolic links, except while processing the com\xe2\x80\x90\n          mand line arguments.  When find examines or  prints  information\n          about  files, the information used shall be taken from the prop\xe2\x80\x90\n          erties of the symbolic link itself.  The only exception to  this\n          behaviour is when a file specified on the command line is a sym\xe2\x80\x90\n          bolic link, and the link can be resolved.  For  that  situation,\n          the  information  used is taken from whatever the link points to\n          (that is, the link is followed).  The information about the link\n          itself  is used as a fallback if the file pointed to by the sym\xe2\x80\x90\n          bolic link cannot be examined.  If -H is in effect  and  one  of\n          the  paths specified on the command line is a symbolic link to a\n          directory, the contents  of  that  directory  will  be  examined\n          (though of course -maxdepth 0 would prevent this).\n
Run Code Online (Sandbox Code Playgroud)\n

你可能想要

\n
find -H /bin -iname \'sh*\'\n
Run Code Online (Sandbox Code Playgroud)\n

或者

\n
find /usr/bin -iname \'sh*\'\n
Run Code Online (Sandbox Code Playgroud)\n

遵循/bin符号链接但保留其下方的默认行为。

\n

  • 或 `find /bin/` 强制它解析到目标目录的符号链接,这与 `-H` 的作用几乎相同 (2认同)