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 11:52 AM, David Kramer wrote:
> Is there a linux tool that can work as a pipe (read stdin, write to std=
out) 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.

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.

--=20
Jerry Feldman <gaf-mNDKBlG2WHs at public.gmane.org>
Boston Linux and Unix
PGP key id: 537C5846
PGP Key fingerprint: 3D1B 8377 A3C0 A5F2 ECBB  CA3B 4607 4319 537C 5846



_______________________________________________
Discuss mailing list
Discuss-mNDKBlG2WHs at public.gmane.org
http://lists.blu.org/mailman/listinfo/discuss






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 / webmaster@blu.org