fgrep Commandįgrep or the Fixed grep or grep -F is yet another version of grep which is fast in searching when it comes to search for the entire string instead of regular expression as it doesn’t recognize the regular expressions, neither any meta-characters. But, when these characters were escaped, then egrep treated them as part of string and searched for complete string “(f|g)ile” in the file. Like here, egrep searched for “file” string when the meta-characters were not escaped as it would mean by the meaning of these characters. In case of egrep, even if you do not escape the meta-characters, it would treat them as special characters and substitute them for their special meaning instead of treating them as part of string. It uses ERE or the Extended Regular Expression set. This version of grep is efficient and fast when it comes to searching for a regular expression pattern as it treats meta-characters as is and doesn’t substitute them as strings like in grep, and hence you are freed from the burden of escaping them as in grep. Egrep CommandĮgrep or grep -E is another version of grep or the Extended grep. But when the special characters were escaped, then instead of treating them as part of string, grep treated them as meta-characters and searched for words “file” or “gile” in the file. Like here, when the command is run without escaping '(' ')' and '|' then it searched for the complete string i.e. Suggested Read: 11 Advance ‘Grep’ Commands on Character Classes and Bracket ExpressionsĪlso, grep uses Boyer-Moore algorithm for fast searching any string or regular expression. ', '(',')', '|', '+', '?' loose their meaning and are treated as normal characters of string and need to be escaped if they are to be treated as special characters.Like: “(a|b)cde” would match either ‘abcde’ or ‘bbcde’. | – Matching either of the expression separated by '|'.? – This denotes almost 1 repetition of previous character. + – Equivalent to one or more occurrences of previous character.‘grep’, ‘egrep’ and ‘fgrep’ of grep that makes Linux users choose one or the other version as per requirement. Main thing that remains to be investigated is what are the differences between the three main variants i.e. But these variants have minor differences to original grep which has made them popular and to be used by various Linux programmers for specific tasks. Difference Between grep, egrep and fgrep in Linuxĭue its varying functionalities, it has many variants including grep, egrep ( Extended GREP), fgrep ( Fixed GREP), pgrep ( Process GREP), rgrep ( Recursive GREP) etc. It is very vast in functionality which can be attributed to the large number of options it supports like: searching using string pattern, or reg-ex pattern or perl based reg-ex etc. One of the renowned search tool on Unix-like systems which can be used to search for anything whether it be a file, or a line or multiple lines in file is grep utility.
0 Comments
Leave a Reply. |