使用终端查找Google Chrome安装目录


9

如何使用命令行找到Google Chrome安装目录/路径? Google Chrome是否始终安装在默认路径“/ Applications /”文件夹中?

我尝试了以下命令。任何人都可以建议我做错了什么?

  1. locate "*Chrome.app"

    当我使用此命令时,它只搜索已安装软件的DB条目。

  2. find / -type d -name "*Chrome.app"

    列出系统上的所有文件。

如何使用此命令仅查找Google Chrome的路径,还是有其他方法?


如前所述,find命令应该工作得更好的版本是不包括* - 它实际显示了什么?
Mark

你为什么需要这条路?
Mark

Answers:


13

您可以使用Launch Services数据库查询此类信息,以转储所有已注册应用程序的列表 grep 对于你想要的人(例如谷歌Chrome),例如(使用Mountain Lion 10.8.4):

/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -dump | grep -i "google chrome"

给我输出:

path:          /Applications/Google Chrome.app/
executable:    Contents/MacOS/Google Chrome
path:          /Applications/Google Chrome.app/Contents/Versions/27.0.1453.116/Google Chrome Helper.app/
executable:    Contents/MacOS/Google Chrome Helper

1
我们的Mac OS 10.13.3上的可执行路径是相同的(/ Applications / Google Chrome.app/Contents/MacOS/Google Chrome)
Stefan Reich


3

你的第二个命令

find / -type d -name "*Chrome.app" 

应该工作 - 它在我的系统上运行正常。

你在“列出系统中的所有文件”是什么意思? “find”将按照您的指定从'/'搜索您的文件系统,但如果您认为Chrome.app可以安装在某个奇怪的地方,“find”是找到它的一种可靠方法。


嗨基思,谢谢你的回复。我需要只使用终端找到应用程序的绝对路径(谷歌浏览器),我将在我的MDM锌应用程序中使用该命令。我的项目要求
remixabhi

如果您的意思是“在文件系统上找到所有Chrome安装”,那么“查找”就会提供这些路径。
Keith Flower
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.