Mark up matching text when using grep

TIL you can mark up matching text when using grep`.

I use grep several times on a daily basis—usually to quickly find something in log files. The result of grep can potentially be thousand lines. Luckily, we have the option --color which marks up the matching text when using grep.

According to man grep:

--colour=[when, --color=[when]]
             Mark up the matching text with the expression stored in GREP_COLOR environment variable.  The possible values
             of when can be `never', `always' or `auto'.

So if we would have a file with Lorem Ipsum text in it and we run the command:

grep --color "non" lorem.txt

The word non will be highlighted in the result:

Example

This really makes grepping easier 🤓


SHARE THIS ARTICLE