I'm guessing it's not a Perl Compatible Regular Expression, since there's a special kind of grep
which is specifically PCRE. What's grep
most similar to?
Are there any special quirks of grep
that I need to know about? (I'm used to Perl and the preg
functions in PHP)
grep is one of the most useful and powerful commands in Linux for text processing. grep searches one or more input files for lines that match a regular expression and writes each matching line to standard output.
You can also use the grep command to search for targets that are defined as patterns by using regular expressions. Regular expressions consist of letters and numbers, in addition to characters with special meaning to grep . These special characters, called metacharacters, also have special meaning to the system.
Different Flavors of Regular Expressions Regular expressions (RE), as defined by POSIX, come in two flavors: extended regular expressions (ERE) and basic regular expressions (BRE). EREs are roughly those of the traditional egrep, while BREs are roughly those of the traditional ed.
A grep pattern, also known as a regular expression, describes the text that you are looking for. For instance, a pattern can describe words that begin with C and end in l.
Default GNU grep
behavior is to use a slightly flavorful variant on POSIX basic regular expressions, with a similarly tweaked species of POSIX extended regular expressions for egrep
(usually an alias for grep -E
). POSIX ERE is what PHP ereg()
uses.
GNU grep
also claims to support grep -P
for PCRE, by the way. So no terribly special kind of grep
required.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With