linux 下less命令配合grep命令高亮

使用grep命令的时候会高亮搜索的字符串。但是有的时候搜索的结果太多了,需要分页,就要使用less

grep “find string” file |less

此时因为使用了less 结果中不会对搜索的字符串高亮。不知道有没有什么办法可以使搜索的字符串也高亮

阅读 5.2k
2 个回答
grep “find string” file |less -R
新手上路,请多包涵

grep 'find string' file --color=auto
一般我喜欢使用grep -A 20 'find string' file --color=auto

推荐问题