Grep is a very useful Linux command. In short grep searches an input stream for a pattern and displays the results. In this guide I will show you how to colorize the output of grep by highlighting the pattern you were searching for.
Supposing that you are using the bash shell open ~/.bashrc with your favorite text editor:
and paste the following line:
alias grep="grep --color=auto"
Now open a new terminal (or source ~/.bashrc) and try the grep command. This is how the default and colorized grep look like:
Of course you can change those colors. In ~/.bashrc to change the foreground color paste the following line:
or to change bot foreground and background
Here is the output of grep.
The first number indicates that we want the font to be bold. The second one is the foreground (the text's) color, and the third one is the background color. Here is a list with the color numbers of the shell.