grep is a command line tool that searches text files for lines with matching text patterns and displays them.
It’s commonly used along with the pipe | symbol from commands that output text.
For example if you want to search the syslog for references to devices you could use: cat /usr/log/syslog | grep device which will display lines in the log with the word “device” in them.
It accepts an option call color which will change the colour of the search term so it’s highlighted in the output. E.g. cat /usr/log/syslog | grep –color=auto
To permanently set this colorised output you can use: export GREP_OPTIONS=’–color=auto’ in the shell startup script.
Leave a Reply