Using grep (or some other tool) to highlight, instead of grepping?

View: New views
3 Messages — Rating Filter:   Alert me  

Using grep (or some other tool) to highlight, instead of grepping?

by Richard Hartmann :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all,

most of you will be familiar with colored grep output like

 grep --color=auto

I was wondering if there is a tool that will allow me to simply
highlight whatever I am looking for without actually grepping. I could,
of course, use --context=999999, but that would be a waste of memory &
processing time, especially with larger files.

Any ideas?


Thanks,
Richard



Re: Using grep (or some other tool) to highlight, instead of grepping?

by Ralf Wildenhues :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Richard,

* Richard Hartmann wrote on Tue, Aug 12, 2008 at 09:11:56PM CEST:
>
>  grep --color=auto
>
> I was wondering if there is a tool that will allow me to simply
> highlight whatever I am looking for without actually grepping.

I guess if you translate your basic regex into an extended one, then you
should be able to use egrep/grep -E, and also match end-of-line:
  grep -E --color=auto 'foo|$'

Hmm.  Using ^ instead of $ destroys the coloring, that looks like a bug
(Debian package grep-2.5.1.ds2-6).

Other than that, editors can typically highlight search matches:
  vim -c 'set hls | /foo' FILE

Hope that helps.

Cheers,
Ralf



Re: Using grep (or some other tool) to highlight, instead of grepping?

by Ralf Wildenhues :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

* Ralf Wildenhues wrote on Fri, Aug 15, 2008 at 05:48:23AM CEST:
>
> I guess if you translate your basic regex into an extended one, then you
> should be able to use egrep/grep -E, and also match end-of-line:
>   grep -E --color=auto 'foo|$'

Erm, or just
   grep --color=auto -e foo -e '$'

> Hmm.  Using ^ instead of $ destroys the coloring, that looks like a bug
> (Debian package grep-2.5.1.ds2-6).

Seems to have been fixed since upstream.

Cheers,
Ralf


LightInTheBox - Buy quality products at wholesale price!