News for hackers. Stuff that matters.
Re:Everything you ever wanted to know about terminals (2018) by inetknght on Thursday September 10, 2020 @09:58PM (#24438437)
If I wanted to see just orange-box, then I would do

    grep --color=always orange-box file.txt
But, I don't want to see just orange-box. I want to see orange-box and compare against other cases of box. So I would do:

    grep --color=always box file.txt | grep --color=always orange-box
Without that --color=always, other cases of box will be drowned out by the noise.

And if I wanted to write that out to a file then I would do

    grep --color=never orange-box file.txt > matches.txt
Alternatively, I'd add a filter to the file with `ansi2txt`

    grep --color=always box file.txt | grep --color=always box | ansi2txt > no-color-matches.txt
Re:Everything you ever wanted to know about terminals (2018) by rixed on Thursday September 10, 2020 @11:38PM (#24438945)
I think the point the person you are replying to was trying to make is that in your proposed sequence of colored greps, the second one would not catch the "orange-box"es because of the extra chars added for coloring the output of the first grep.

Maybe grep should ignore ansi sequences optionally or by default, to solve this?