help-bash
[Top][All Lists]
Advanced

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

Re: Printing in red during output from head


From: Greg Wooledge
Subject: Re: Printing in red during output from head
Date: Wed, 21 Jul 2021 12:36:34 -0400

On Wed, Jul 21, 2021 at 06:27:17PM +0200, lisa-asket@perso.be wrote:
> * I would like to colour the lines showing the file names

So you don't need a *specific* color?  Another change to the problem
spec.  But the good news is, this one actually makes it *easier* instead
of harder.

GNU grep can do this, although the exact mechanism is a bit
counterintuitive:

yourthing | grep --color -e ^ -e '^==>.*'

The first -e ^ tells grep to match (and therefore print) every line,
no matter what.  But since it's an empty pattern, it doesn't cause every
line to be colored.  The second -e pattern tells grep to match only
specific lines -- and since this pattern isn't empty, the lines that
match it will be colored.

If you actually care which color gets used, you can read the GNU grep
documentation and try to figure out how to configure it.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]