
In the above output, we can see that the dot (.) character matched the text har, hat, and has. This simple regular expression matches any single character except for the end of the line: $ grep ha. To understand the difference, let’s use a dot (.) character with the grep command. Hence it performs the search operation in a time-efficient way. It interprets the pattern as a fixed string instead of a regular expression. How fgrep Is Different than grep and egrep Commands?Īs the name suggests, the fgrep command is used to search for the fixed string patterns. Now let’s discuss some common examples of the fgrep command in the next few examples. Here, we can see that the text file is ready with the sample contents. To begin, let’s create a plain text file with the following contents to use an example: $ cat input.txt The syntax of the fgrep command is similar to the other grep family commands: $ fgrep PATTERNS Hence the name of the command is fgrep ( Fixed GREP). However, it is used to search for the fixed string pattern instead of regular expressions. The fgrep command in Linux falls under the family of the grep command.

In this guide, we are going to discuss some practice examples of the fgrep command that can be used in day-to-day life. However, in Linux, fgrep is the most preferred utility for simple text searching. In Linux, there are various text-filtering utilities such as awk, sed, cut, etc. However, this simple task quickly becomes time-consuming if users are not familiar with the correct tools. Text searching is one of the most commonly performed operations. By the end of this guide, users will be able to perform text search operations efficiently using the command line interface. Brief: In this beginner-friendly guide, we will discuss some practical examples of the fgrep command.
