Regular Expressions Versus Wildcards

The Korn shell uses a form of regular expressions similar to those used by grep, awk, sed, and other programs. Be aware that the regular expressions used by utilities such as sed and grep are not to be confused with filename expansion used by the shell.

Unfortunately, most syntax used for filename expansion expressions (sometimes called wildcards) is the same as the syntax used for string pattern-matching regular expressions. You must take a breath and ask yourself what you are trying to do. Does it involve filenames, or does it involve string patterns? The next sequence shows some filename expansion (wildcards) expressions being used:

 $ ls obr obrr obrrr regextest # four files in the directory $ $ $ ls obr ...

Get Korn Shell Programming by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.