Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos “命令”;定位;在MAC终端中_Macos_Shell_Locate - Fatal编程技术网

Macos “命令”;定位;在MAC终端中

Macos “命令”;定位;在MAC终端中,macos,shell,locate,Macos,Shell,Locate,我开始在我的计算机(iMAC)上学习CLI,并使用命令查找。当我使用这个命令时,搜索不是在当前目录中进行的,而是在任何地方进行的。此外,此命令会扫描所有系统和程序文件,但不会扫描下载或音乐库中的文件 在这方面,我有两个问题: 如果我没有指定搜索目录,那么这个命令将在哪里搜索我的文件(在根目录或其他地方) 如何为此命令指定搜索目录(例如,我需要查找仅在下载中的文件) 尝试手册页: 您可能还对查找感兴趣: 我使用的“查找”远不止“定位”,但您的问题的答案都在文档中。事实证明,在我的MAC上,用

我开始在我的计算机(iMAC)上学习CLI,并使用命令查找。当我使用这个命令时,搜索不是在当前目录中进行的,而是在任何地方进行的。此外,此命令会扫描所有系统和程序文件,但不会扫描下载或音乐库中的文件

在这方面,我有两个问题:

  • 如果我没有指定搜索目录,那么这个命令将在哪里搜索我的文件(在根目录或其他地方)
  • 如何为此命令指定搜索目录(例如,我需要查找仅在下载中的文件)
尝试手册页:

您可能还对
查找
感兴趣:


我使用的“查找”远不止“定位”,但您的问题的答案都在文档中。

事实证明,在我的MAC上,用户“所有人”的下载文件夹通常是关闭的,系统文件是打开的,可以阅读!哇!更改权限和更新数据库后,一切正常。现在的问题仍然是:只有我拥有这样的默认权限?

问题在于:您正在寻找一个用于优化搜索操作的Mac cli工具(搜索引擎索引),Mac上不支持
定位
工具(熟悉unix/linux)(启用它有一个变通方法,但这是另一个主题)

解决方案:尝试
mdfind
terminal命令(与linux中的
locate
命令类似)

(来自文档)
mdfind
命令查阅中央元数据存储并返回与给定元数据查询匹配的文件列表。查询可以是字符串或查询表达式

示例

/* input: */
mdfind -name configuration.yml

/* output: */    
/Users/someUser/x/y/z/configuration.yml
/Users/someUser/a/b/c/d/e/f/g/h/i/configuration.yml
/System/Library/someApp/someVersion/someDir/configuration.yml
可选标志为:

 -0          Prints an ASCII NUL character after each result path.  This is useful when used in conjunction with xargs -0.

 -live       Causes the mdfind command to provide live-updates to the number of files matching the query.  When an update causes the query results to change the number of matches
             is updated.  The find can be cancelled by typing ctrl-C.

 -count      Causes the mdfind command to output the total number of matches, instead of the path to the matching items.

 -onlyin dir
             Limit the scope of the search to the directory specified.

 -name fileName
             Searches for matching file names only.

 -literal    Force the provided query string to be taken as a literal query string, without interpretation.

 -interpret  Force the provided query string to be interpreted as if the user had typed the string into the Spotlight menu.  For example, the string "search" would produce the
             following query string:
                   (* = search* cdw || kMDItemTextContent = search* cdw)

是的,通常会有一个运行
updatedb
的计划作业来执行此操作,但它们不会立即显示。堆栈溢出用于编程问题。您可以尝试询问,也可以改为询问。