Colour highlighting output based on regex in shell

后端 未结 8 1915
鱼传尺愫
鱼传尺愫 2020-12-02 07:32

I\'d like to know if I can colour highlight the output of a shell command that matches certain strings.

For example, if I run myCommand, with the output below:

8条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-02 08:16

    Try

    tail -f yourfile.log | egrep --color 'DEBUG|'
    

    where DEBUG is the text you want to highlight.

提交回复
热议问题