I work with a lot of text data. Be it log files, xml formatted data or just simple html files somebody usually claims something is being correctly displayed in a website or particular information that should have been processes was not processed correctly. In such cases, I usually turn to grep. So, what is grep? In it's most simple form, grep searches through a file and looks for lines containing a match to a given pattern. grep then prints these matches to the console unless you redirect the output somewhere else including a file or another program. That is the power of the console, you can redirect the output to other devices including the monitor, file or another program like sed or awk which we will cover in other articles.
grep in its simple from follows follows this muster:
grep [options] pattern file
grep => is the program name
[options] => are just that, optional. If you type man grep in your console you can read about the options available, for example -i which means to ignore the case of the pattern. The pattern you are searching with grep is case sensitive. Cat is different than cat or CAT. If you want your search to be case insensitive then you use the flag (option) -i
pattern is the search pattern. For example CAT. If you do not use the flag -i as mentioned in the options you will find only occurrences of CAT but be careful as you will also find
file => is the file name.
This was a quick introduction to grep. If you can't wait for the follow up articles then use man grep and experiment.