On 01/18/2011 02:08 PM, Daniel Hedlund wrote: > On Wed, Dec 29, 2010 at 08:52, David Kramer <da...@thekramers.net> 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. > > egrep (grep -E) does this, at least the version I'm using does: > > cat /etc/services | egrep --color=auto '#.+$' > cat /etc/services | egrep --color=always ''#.+$'' | less -R > > # change match color to bright green > export GREP_COLOR='1;32' > cat /etc/services | egrep --color=always ''#.+$'' | less -R > > > I usually alias less="less -R" in my bashrc so I don't have to > remember to add that every time.
Thanks. I played with this, and with colortail. I didn't really like either solution in the end. [e]grep only allows one color and one pattern, and colortail doesn't actually work as a filter (the author "has a patch for that"). I ended up going with a perl script I wrote, which lets me have different patterns output with different colors, and our developers already have perl, not colortail, _______________________________________________ Discuss mailing list Discuss@blu.org http://lists.blu.org/mailman/listinfo/discuss