Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Blog | Linux Links | Bling | About BLU

BLU Discuss list archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Colorize text matching a regex through a pipe?

On 12/29/2010 02:27 PM, Jerry Feldman wrote:
> On 12/29/2010 11:52 AM, David Kramer wrote:
>> Is there a linux tool that can work as a pipe (read stdin, write to stdout) and colorize any text
>> matching an regex?  If not, I'll have to write one.  Not that hard, but I would hate to reinvent
>> it.
> While I'm not specifically answering this, I do want to comment on
> terminology. First, a PIPE is a channel that can connect 2 ports. In
> this case, the output of 1 program to the input of another program. A
> Unix program that reads from stdin and outputs to stdout (most Unix
> commands) is called a FILTER when used in this context. For instance,
> the pr(1) command is almost always used in this context. As also
> mentioned, grep(1) is also a filter, and many times it is:
> cat foo | grep <pattern> | grep -v <excluded stuff>
> This is kind of an example of using grep as a filter.

Yup.  I meant filter.  Thanks.  I was trying to fit the email in during
a compile cycle, so I didn't give it as much thought as I should have.

While "I knew what I meant", thank you for clarifying in case I
confuzled anyone on the list.

> I don't think that grep is the answer, but sed(1) is another command
> that can alter a line of text based upon regular expressions. I don't
> know exactly what you mean by colorize, but you certainly can take one
> or more patterns(regex) and convert them to whatever you want.

Yes, sed would be much more appropriate for this that grep (because I
use search and replace to do more complicated things), if colorize
doesn't work out for some reason.

BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!

Boston Linux & Unix /