【问题标题】:How to open in interface user the result of grep?如何在界面用户中打开 grep 的结果?
【发布时间】:2024-01-11 18:36:01
【问题描述】:

几周后,我创建了一个脚本 (bash) 来使用终端的 mac 查找一些文件。

如何在mac的文件夹界面中打开所有找到的文件的结果? (即像mac的finder)

我尝试使用命令打开的命令 xargs 但找到的每个文件都是打开的,我想在同一个屏幕中找到所有结果因为我可以进行预览等。

这是我的脚本:

grep -irEl --exclude-dir={"*sys"} "word to find" /Users/ponne/Desktop/Test | xargs ls -lah 

【问题讨论】:

  • 请更新标签以显示这是特定于 mac 的。这确实是一个关于查找显示指定文件列表的 Mac GUI 的问题 - 一旦您知道这一点,只需将您的 ls 替换为它。这根本不是一个 bash/terminal/grep 问题。

标签: bash macos terminal grep


【解决方案1】:

这能解决您的问题吗?

ls -alh $( grep -irEl --exclude-dir={"*sys"} "word to find" /Users/ponne/Desktop/Test)

【讨论】:

  • 不,它不能解决我的问题。我执行您的代码,但它不能满足我的需要/要求。我会在同一个窗口中打开所有结果。 (我在 MacOS 中在终端中执行脚本并希望在窗口查找器中打开结果)
最近更新 更多