Tuesday, May 16, 2006

Colourful GREP


This is how GNU defines GREP
" The grep command searches one or more input files for lines containing a match to a specified pattern. By default, grep prints the matching lines. "

grep basically searches. To be more precise,

grep bacteria food returns all the lines that contain a string matching the expression "bacteria" in the file "food".
If we assume an expression as a string. So grep returns all matching lines that contain bacteria as a substring.

Another way of using grep is to have it accept data through STDIN. instead of having it search a file. For example,

ls |grep vindo lists all files in the current directory whose names contain the string "vindo"


Now I guess you know how grep works.In case you are still in doubt about GREP please ask Mr.Google. My main objective of writing this blog is to introduce the normal unix users to the colourful version of grep.So when u search for the term it will become automatically highlighted. Just check out the sreenshot on top.

How can I do it ?

Well one just needs to edit his/her .bashrc file and put up an alias for grep.

alias G=' grep -ni --color=auto '

That's it done .Your colourfull grep is ready for use :)