changing grep command –color from red to another color

I’m searching from the file using grep command with particular pattern,
sysadmin@localhost:~$ grep bash /etc/passwd

which return the output like below
root:x:0:0:root:/root:/bin/bash operator:x:1000:37::/root:/bin/bash sysadmin:x:1001:1001:System Administrator,,,,:/home/sysadmin:/bin/bash

How can I change the default color of red to something different (

Asked By: SpiderMan


The simple solution:

Add --color=always to the grep options… then pipe the result into
| sed -re 's/31m/32m/' and you will get green text instead of the red.

Another way is described in the man page:
$ man grep, then
type /_COLOR hit enter, hit n once
(alternatively type /^ +GREP_COLOR$and hit enter)

Answered By: Hannu