Regular expressions

Metacharacters in regular expressions

Any character that has a special meaning to the shell is a ``metacharacter''. For example, some punctuation marks, such as the period (.) and question mark (?), have a special meaning in some contexts that will cause the shell to try interpreting them rather than just reading them. One set of metacharacters is used to group commands. See, for example, ``Entering commands on the same line'' and ``Running commands in a pipeline''.

In addition, there are two families of regular expression metacharacters, the ``Wildcard characters'' used for matching filenames, and the more complex ``Editor regular expressions'' metacharacters, which are used to match text strings within files. The asterisk is a wildcard character denoting any string consisting of zero or more characters.

These simple patterns are expanded by the shell, not by the program ls used in this example. All the shells recognize the same family of wildcard characters.

The second family of regular expressions is much more complex, and is used by such programs as ed(1), sed(1), awk(1), vi(1), and grep(1). The editor regular expressions are used to search for text in files, rather than to search for files in directories. They are explained in ``Editor regular expressions''.

© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 22 April 2004