Colorized grep — viewing the entire file with highlighted matches

前端 未结 21 2437
野趣味
野趣味 2020-11-28 00:17

I find grep\'s --color=always flag to be tremendously useful. However, grep only prints lines with matches (unless you ask for context lines). Give

21条回答
  •  遥遥无期
    2020-11-28 00:48

    To highlight patterns while viewing the whole file, h can do this.

    Plus it uses different colors for different patterns.

    cat FILE | h 'PAT1' 'PAT2' ...
    

    You can also pipe the output of h to less -R for better reading.

    To grep and use 1 color for each pattern, cxpgrep could be a good fit.

提交回复
热议问题