Colorize tail output

后端 未结 6 689
慢半拍i
慢半拍i 2021-01-30 07:27

I\'ve been trying to make tail a little more readable for server startups. My current command filters out most of the INFO and DEBUG messages from the startup:

         


        
6条回答
  •  忘了有多久
    2021-01-30 07:57

    I wrote a script for this years ago. You can easily cover the case of multiple colors by piping successive invocations of highlight to each other.

    From the README:

    Usage: ./highlight [-i] [--color=COLOR_STRING] [--]  [PATTERN1...]
    
    This is highlight version 1.0.
    
    This program takes text via standard input and outputs it with the given
    perlre(1) pattern(s) highlighted with the given color.  If no color option
    is specified, it defaults to 'bold red'.  Colors may be anything
    that Perl's Term::ANSIColor understands.  This program is similar to
    "grep --color PATTERN" except both matching and non-matching lines are
    printed.
    
    The default color can be selected via the $HIGHLIGHT_COLOR environment
    variable.  The command-line option takes precedence.
    
    Passing -i or --ignore-case will enable case-insensitive matching.
    
    If your pattern begins with a dash ('-'), you can pass a '--' argument
    after any options and before your pattern to distinguish it from an
    option.
    

提交回复
热议问题