bug-grep
[Top][All Lists]
Advanced

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

bug#55641: Using colours with grep


From: Gary Johnson
Subject: bug#55641: Using colours with grep
Date: Sat, 28 May 2022 11:38:26 -0700
User-agent: Mutt/1.5.20 (2009-06-14)

On 2022-05-28, goncholden wrote:
> I was trying to change the colours used for matching temporarily.
> But GREP_COLORS is global in nature.

An environment variable such as GREP_COLORS set by itself on the
command line persists in the environment after it has been set.  An
environment variable set on the same line as a command, such as

    GREP_COLORS='ms=01;32' grep this_pattern that_file

affects only the environment of that command, persists only for the
duration of that command, and does not affect the shell's
environment.

That may not be completely accurate, but it's close.

So, setting GREP_COLORS on the grep command line as above will
affect only that command and will not affect the "global" setting,
as you put it.

See the ENVIRONMENT section of the bash(1) man page.

Regards,
Gary






reply via email to

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