Colorized grep — viewing the entire file with highlighted matches

前端 未结 21 2497
野趣味
野趣味 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:45

    Here's something along the same lines. Chances are, you'll be using less anyway, so try this:

    less -p pattern file
    

    It will highlight the pattern and jump to the first occurrence of it in the file.

    You can jump to the next occurence with n and to the previous occurence with p. Quit with q.

提交回复
热议问题