我知道如何为grep、ls(256种颜色!)、prompt和tail着色。但像我这样的重度find用户,真正提高生产力的将是带有颜色的find输出。
这种东西是否存在?我进行了一些网络搜索,但没有找到有希望的结果。'find'是一个如此通用的词汇,也不能起到帮助作用 :-)
grc适用于花式着色,但简单的高亮可以使用grep完成。诀窍是额外添加一个-e ^
,它匹配每行的空位。
$ ls dull.txt interesting.txt really_interesting.txt $ find * -printf '%a %p\n' | grep --color=auto -e ^ -e "[a-z_]*interesting" Wed Feb 8 17:01:49.0685605700 2012 dull.txt Wed Feb 8 17:01:49.0686582300 2012 interesting.txt Wed Feb 8 17:01:49.0688535400 2012 really_interesting.txt
在Markdown中无法显示颜色,我在上面使用了粗体表示我控制台中的红色。
对于我的grep示例,有很多替代选项可用于--color=auto
。
find * -iname *Test* -exec ls --color=auto -d {} \; | grep -i Test
您也可以像下面这样创建别名:
myfind() { find * -iname "*$1*" -exec ls --color=auto -d {} \; | grep -i $1 ; }
find -exec ls --color=always {} \; | head
。有什么想法为什么? - Sridhar Sarnobat有一个用Rust编写的新工具,它自称为“find”的简单、快速和用户友好的替代品:
个人经历来说,我对它没有很好的体验,它会破坏很多Unix友好(line-oriented, Unix哲学原则)的功能,而我的脚本和管道需要这些功能。并且它没有一些find
的功能。
find SEARCH_PATH -name "SEARCH_KEY" | grep --color=auto SEARCH_KEY
find . -name "apple" | grep --color=auto apple