Answers:
对于快速搜索(但不是确定的):
locate -br '^settings.xml$'
来自man locate:
locate reads one or more databases prepared by updatedb(8) and writes
file names matching at least one of the PATTERNs to standard output,
one per line.
-b, --basename
Match only the base name against the specified patterns. This
is the opposite of --wholename.
-r, --regexp REGEXP
Search for a basic regexp REGEXP. No PATTERNs are allowed if
this option is used, but this option can be specified multiple
times.
在^和$确保只有文件名为settings.xml而不是文件名称中包含 settings.xml将被打印出来。
您可能需要首次运行:(updatedb如root)来更新/构建的数据库locate。
man locate!!!假设它只是简单的搜索工具。非常感谢你。
updatedb,此命令的作用- locate无论如何,对于我而言,经常会失败
updatedb。谢谢。
locate '*/settings.xml'在各种不同的实现中locate(可能的话)可能更容易移植。
缓慢而稳定地搜索文件系统,但确定。
find / -xdev -name settings.xml
这将需要一些时间,并且您可能会遇到一些权限错误,但是会到达那里。如果您进一步了解它可能位于的位置,请将第一个目录从更改/为/where/you/guess
2>/dev/null到命令末尾将抑制所有错误输出(通过将stderr重定向到空设备)。
-xdev注意:不要降级其他文件系统上的目录。
树是另一种好方法,如果不确定所要查找的是什么,它似乎会更快一些:
tree -f / | grep settings.xml
其他有用的标志:
-i在grep上将忽略大小写,
-h以便在树上易于阅读-
-手册页有很多有用的选项-!
tree(1)显示了文件的ASCII码艺术树,然后将其残废grep(1)。
tree,则最好使用find . type -f速度更快的方法。
ls,几乎肯定会以错误的方式进行操作。