UNIX 彩色查找输出
我知道如何为 grep、ls(256 种颜色!)、prompt 和 tail 的输出着色。但真正能提高像我这样的重度查找用户的工作效率的是彩色查找输出。
这样的事存在吗?一些网络搜索对我来说没有产生有希望的结果。 “查找”是一个如此通用的词,这并没有帮助:-)
I know how to color the output of grep, ls (in 256 colors!), prompt and tail. But what would really enhance productivity of a heavy find user like me would be colored find output.
Does such a thing exist? Some web searching yields no promising results for me. It doesn't help that 'find' is such a generic word :-)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
据我所知 find 没有内置这个功能。对于这样的情况,我喜欢使用 grc (查看 https://manpages.ubuntu.com/manpages/jammy/en/man1/grc.1.html)。希望这有帮助!
As far as I know find doesn't have this built in. For situations like these I like to use grc (check out https://manpages.ubuntu.com/manpages/jammy/en/man1/grc.1.html). Hope that's helpful!
您可以将 find 的输出发送到 grep,然后根据需要使用颜色:
您还可以创建一个别名,如下所示:
You can send the output of find to grep and then play with the colors as needed:
You can also create an alias like below:
grc 适合花哨的颜色,但简单的突出显示可以使用 grep 完成。诀窍是一个额外的
-e ^
,它匹配每行的一个空位。对 Markdown 中的颜色感到羞耻。我在上面使用了粗体,我的控制台中有红色。
我在 grep 示例中使用的
--color=auto
有很多替代方案。grc would suit fancy coloring but simple highlighting can be done with grep. The trick is an extra
-e ^
which matches an empty bit of each line.Shame about color in Markdown. I've used bold above where I have red in my console.
There are plenty of alternatives to the
--color=auto
I've used in my grep example.有一个用 Rust 编写的新工具,将自己定位为“查找”的简单、快速且用户友好的替代品:
https://github.com/sharkdp/fd
我个人并没有很好的体验,它破坏了很多unix友好性(面向行,unix 哲学原则)我的脚本和管道所需的功能。并且不具备
find
的一些功能。There's a new tool written in Rust that markets itself as
A simple, fast and user-friendly alternative to 'find'
:https://github.com/sharkdp/fd
I personally haven't had a good experience with it, it breaks a lot of unix-friendly (line-oriented, unix philosophy tenets) functionality that my scripts and pipelines need. And doesn't have some of the features of
find
.这对我来说非常有效
例如,如果您想搜索单词“apple”到处,从当前目录开始:
This worked for me very well
For example, if you want to search for the word "apple" everywhere, starting from the current directory: