You can use the grep command to search for a word /or a character in Linux files. In addition, Linux has egrep and fgrep, which have advanced search capabilities. Here I have discussed these with examples.
The egrep command
It’s also called extended grep. It is identical to the grep -e. The egrep supports for ‘+’, ‘?’ and ‘|’ options. These options are also called regular expressions. Here’s a list of supported regular expressions.
How to use “+” in egrep
With egrep, you can give regular expressions. Here it displayed matching upper and lower case words. The point to note is a “+” symbol is required at the end. Here the “+” means one or more times.
How to use “?” in egrep
The “^” says the letter starts with “g,” and the “?” says any word which can have the letter “g.”
How to use “|” in egrep
It works as or condition. It displays lines that have either of the words. Here, it prints a line that has abc or ABC.
How to use fgrep in Linux
The fgrep is deprecated. Still, the command’s usage is there in many installations. The fgrep is also called fast grep. This is equal to grep -F. The fgrep does not support regular expressions so it is faster.
You must be logged in to post a comment.