Unix Grep

Unix grep is a search command built into a number of Unix Operating Systems. This command was built to make certain tasks simpler.

Unix grep is a command utility whose main purpose is to search for lines matching a given regular expression. Once these lines are found, they will be printed. The user can access the Unix grep command through the command line or terminal from any location in the Unix Operating System.

The Unix grep command becomes particularly useful when the user needs to search through more than one file. This is because Unix grep is capable of searching through any amount of text in order to find the information he is looking for. The lines containing the information will subsequently be displayed on the user’s screen. The user can then easily access the said search results.

To further understand how the Unix grep search command works, here is an example of the said command:

Grep test sample.txt

The first part of the example is the actual command. The second word is the text the user would like to find. The third is the name of the file the user wants to search for all instances of the word “test”.

Since the Unix grep command is inherently case sensitive, the word “Test” will not be seen on the screen, although it may be present in the file. However, by using the “-I” flag before the word the user wants to find, he will be able to deactivate the command’s case sensitive feature.

Below is another example of the Unix grep command:

Grep ‘^or’ sample.txt

Putting a caret will find the “or” word as it appears by itself. This means that words such as “core” and “poor” will not be found and displayed.