Colour highlighting output based on regex in shell

后端 未结 8 1922
鱼传尺愫
鱼传尺愫 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:24

    You can use the hl command avalaible on github :
    git clone http://github.com/mbornet-hl/hl

    Then :
    myCommand | hl -r '^ERROR.*'

    You can use the $HOME/.hl.cfg configuration file to simplify the command line.
    hl is written in C (source is available). You can use up to 42 differents colors of text.

提交回复
热议问题