|
|
Not all of the editor regular expression constructions are recognized by all of the editor programs. The following table categorizes the most common metacharacters and the programs that use them.
Note also that the table covers only the editor regular expression constructions. The wildcard metacharacters are not entirely compatible with the editor regular expression set described below. It is therefore important to be clear about which program will interpret a regular expression. Programs like awk and grep require you to enclose a regular expression on the command line, intended as an argument, in quotes. If you do not, the shell will try to interpret it as a wildcard regular expression, passing on any results to the program. This can have unexpected results.
In the following table, a ``y'' indicates that the command supports the notation.
Regular expressions syntax recognized by programs
Command | Regular expression supported? | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
. | [...] | \(...\) | \{...\} | ? | + | | | () | ^ | $ | \ | ||
grep | y | y | y | y | y | n | n | n | n | y | y | y |
egrep | y | y | y | y | n | y | y | y | y | y | y | y |
awk | y | y | y | n | n | y | y | y | y | y | y | y |
Tcl | y | y | y | y | n | y | y | y | y | y | y | y |
ed | y | y | y | y | y | n | n | n | n | y | y | y |
vi | y | y | y | y | n | n | n | n | n | y | y | y |
sed | y | y | y | y | y | n | n | n | n | y | y | y |