Different commands different REs

Regular expressions are one area in which the heterogeneous nature of UNIX becomes apparent. Different programs on different platforms recognise different subsets of regular expressions. You need to refer to the manual page of the various commands to find out which features it supports. On Linux, you can also check the regex(7) manual page (command: man 7 regex) for more details about the POSIX 1003.2 regular expressions supported by most of the GNU commands used by Linux.

One example of the difference, using the pattern file used above, follows:

[[email protected] tmp]$ grep '.\{2,\}' pattern aaaaaaaaaaa david

This demonstrates how the grep and egrep commands on Linux use slightly different versions of regular expressions.

Was this article helpful?

0 0

Post a comment