Regular expressions

Korn shell regular expressions

In addition to the regular expression notations discussed above, the Korn Shell provides its own syntax. The metacharacters used by this syntax are similar to those used by the generic regular expression handling notations:

Operator Meaning
*(regexp) matches 0 or more instances of regexp
+(regexp) matches 1 or more instances of regexp
?(regexp) matches 0 or 1 instances of regexp
@(regexp1|regexp2|. . .) matches regexp1 or regexp2 or . . .
!(regexp) matches any string except regexp

 --------------------------------------------------------------------
| Operator                  |  Meaning                              |
|---------------------------|---------------------------------------|
| (regexp)                 |  matches 0 or more instances of regexp|
|---------------------------|---------------------------------------|
| +(regexp)                 |  matches 1 or more instances of regexp|
|---------------------------|---------------------------------------|
| ?(regexp)                 |  matches 0 or 1 instances of regexp   |
|---------------------------|---------------------------------------|
| @(regexp1|regexp2|. . .)  |  matches regexp1 or regexp2 or . . .  |
|---------------------------|---------------------------------------|
| !(regexp)                 |  matches any string except regexp     |
|---------------------------|---------------------------------------|
The OR notation given for the @ metacharacter can be combined with any of the other metacharacters. For example, @(apple|pear|kumquat) matches ``apple'' or ''pear'' or ``kumquat'', while !(apple|pear|kumquat) matches any string except ``apple'' or ''pear'' or ``kumquat''.


© 1999 The Santa Cruz Operation, Inc. All rights reserved.
UnixWare 7 Release 7.1.1 - 5 November 1999