我是 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 的解决方案也很好。
太感谢了