小编chi*_*cal的帖子

如何在每次匹配之前在文件名中获取 grep 颜色?

如果我grep -ir "somethingtomatch" .从当前目录运行,我通常会得到如下结果:

./some/path/file1.html: filecontent filecontent keyword filecontent
./some/path/file2.html: filecontent filecontent filecontent keyword
./some/path/file3.html: filecontent keyword filecontent filecontent
./some/path/file4.html: keyword filecontent filecontent filecontent
Run Code Online (Sandbox Code Playgroud)

我使用过,grep --color=auto -ir 'somethingtomatch" .但它只在红色突出显示上以白色突出显示关键字。我也在尝试获取左侧颜色编码的文件名。我怎么做?

我在 OS X 中使用 Terminal.app 和 bash 和 xterm(我也尝试过 xterm-color)。

unix grep colors

6
推荐指数
1
解决办法
5856
查看次数

标签 统计

colors ×1

grep ×1

unix ×1