Just how can I highlight suits making use of GNU grep?

I have actually seen on some Linux, that grep is set up to highlight the suit, and also publish the matching documents.

Just how can I set up grep to highlight suits?

0
2019-05-04 23:42:47
Source Share
Answers: 4

The --color alternative has actually been currently stated numerous times, yet I would certainly such as to add that it's feasible to set up the shade in which the suits will certainly be highlighted making use of a setting variable

export GREP_COLOR="1;33"

The shade need to be inscribed making use of ANSI shade codes, for reference

Black       0;30     Dark Gray     1;30
Blue        0;34     Light Blue    1;34
Green       0;32     Light Green   1;32
Cyan        0;36     Light Cyan    1;36
Red         0;31     Light Red     1;31
Purple      0;35     Light Purple  1;35
Brown       0;33     Yellow        1;33
Light Gray  0;37     White         1;37
0
2019-05-10 14:30:56
Source

I've located that the most effective means to pander grep is to make use of ack, which is basically recursive grep with a smart overlook checklist (as an example, does not search.svn directory sites, overlooks back-up documents, etc), colour highlighting of outcomes and also perl regexps. It's what you desire grep to do 98.6% of the moment.

0
2019-05-08 08:11:06
Source

I set this in my.bashrc, as opposed to redefining grep making use of an alias :

    export GREP_OPTIONS="--color=auto"

For me, this works with Linux, MacOSX & FreeBSD.

0
2019-05-08 07:59:52
Source
alias cgrep='grep -nR --color'
.

Use :

$ cgrep somestring /path/to/dir/or/file/with*/possible/*wild.card
.

Additionally among my faves :

$ pgrep some-hanging-process
.

will certainly detail all pids of procedures that match the name of some - dangling - procedure which you can make use of in adhering to scenario :

$ kill $(pgrep some-hanging-process)
.
0
2019-05-08 06:52:22
Source