Grep on color lines

I wrote a simple PHP shell script that parses files and displays a specific element.
It generates a lot of output. In different colors (bash), green for OK, yellow for warnings, red for errors, etc.

During development, I want to filter out some lines. For example, all lines containing red text.

Can I use a command grep(or another) for this ?

+3
source share
2 answers

I have no idea what your input looks like, but as a proof of concept you can filter any lines in lsoutputs that use green:

ls --color=always | grep '^[\[01;32m'

: http://en.wikipedia.org/wiki/ANSI_escape_code#Colors

. , ^[ Ctrl-V Esc ( Ctrl-V Ctrl-[ ). , grep, \x1B ,

+6

, , , ? "" ? script , myscript --nowarnings

getopt PHP

php, - ():

paintred(string, show){
    match(string);
    if(show){
        print(string) in red;
    }
    else return 0;
}

show .

, .

0

All Articles