【发布时间】:2021-04-13 15:41:54
【问题描述】:
我是 Linux 命令的新手,我正在尝试在目录和包含该单词的所有目录名称中递归搜索“apple”的单词。
我正在使用类似于 grep 的 ripgrep(rg) 来获取其中包含苹果的文件名
例如:
rg -l "apple"
给我输出:
a/fruit.c
b/fruit.c
a/fruits.c
a/fruitsnames.c
a/fruity/fruits.c
b/fru/fruit/fru/fr.c
c/frts.c
有没有办法让我只能使用唯一的父文件夹名称?
Example output I expect is to get only the folder names:
a
b
c
使用 grep 的解决方案也不错。
非常感谢
【问题讨论】: